diff mbox series

[3/7] x86: mtrr: Skip MSRs that were already programmed in mtrr_commit()

Message ID 20210731084529.7524-4-bmeng.cn@gmail.com
State Accepted
Commit 3bcd6cf89efee5c8088dce2f770bdd5592186efb
Delegated to: Bin Meng
Headers show
Series x86: Various fixes to MTRR and FSP codes | expand

Commit Message

Bin Meng July 31, 2021, 8:45 a.m. UTC
At present mtrr_commit() programs the MTRR MSRs starting from
index 0, which may overwrite MSRs that were already programmed
by previous boot stage or FSP.

Switch to call mtrr_set_next_var() instead.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 arch/x86/cpu/mtrr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Glass Aug. 1, 2021, 7:19 p.m. UTC | #1
On Sat, 31 Jul 2021 at 02:45, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> At present mtrr_commit() programs the MTRR MSRs starting from
> index 0, which may overwrite MSRs that were already programmed
> by previous boot stage or FSP.
>
> Switch to call mtrr_set_next_var() instead.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
>  arch/x86/cpu/mtrr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Tested on chromebook_coral, chromebook_samus, chromebook_link, minnowmax
Tested-by: Simon Glass <sjg@chromium.org>
Bin Meng Aug. 2, 2021, 2:50 a.m. UTC | #2
On Mon, Aug 2, 2021 at 3:19 AM Simon Glass <sjg@chromium.org> wrote:
>
> On Sat, 31 Jul 2021 at 02:45, Bin Meng <bmeng.cn@gmail.com> wrote:
> >
> > At present mtrr_commit() programs the MTRR MSRs starting from
> > index 0, which may overwrite MSRs that were already programmed
> > by previous boot stage or FSP.
> >
> > Switch to call mtrr_set_next_var() instead.
> >
> > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > ---
> >
> >  arch/x86/cpu/mtrr.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Tested on chromebook_coral, chromebook_samus, chromebook_link, minnowmax
> Tested-by: Simon Glass <sjg@chromium.org>

applied to u-boot-x86, thanks!
diff mbox series

Patch

diff --git a/arch/x86/cpu/mtrr.c b/arch/x86/cpu/mtrr.c
index 73cf7bb2be..14c644eb56 100644
--- a/arch/x86/cpu/mtrr.c
+++ b/arch/x86/cpu/mtrr.c
@@ -155,7 +155,7 @@  int mtrr_commit(bool do_caches)
 	debug("open done\n");
 	qsort(req, gd->arch.mtrr_req_count, sizeof(*req), h_comp_mtrr);
 	for (i = 0; i < gd->arch.mtrr_req_count; i++, req++)
-		set_var_mtrr(i, req->type, req->start, req->size);
+		mtrr_set_next_var(req->type, req->start, req->size);
 
 	debug("close\n");
 	mtrr_close(&state, do_caches);