Skip to contentSkip to conversation

x86: Avoid using hardcoded number of variable range MTRRs in mtrr_commit()

PATCH New Bin Meng 2 participants 4 messages Nov 9, 2020 – Nov 10, 2020 x86

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/1 x86: Avoid using hardcoded number of variable range MTRRs in mtrr_commit()

Since commit 29d2d64ed55f ("x86: Add support for more than 8 MTRRs"), the maximum number of variable range MTRRs was increased from 8 to 10, which caused a #GP exception during VESA video driver probe.

On the BayTrail platform there are only 8 variable range MTRRs. In mtrr_commit() it still uses MTRR_MAX_COUNT which should have been updated to use dynamically probed number.

This fixes the boot failure seen on Intel Minnow Max board.

Fixes 29d2d64ed55f ("x86: Add support for more than 8 MTRRs")

---

 arch/x86/cpu/mtrr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/cpu/mtrr.c +1 -1
index 5180eb0..6f095c5 100644
@@ -158,7 +158,7 @@ int mtrr_commit(bool do_caches)
 
 	/* Clear the ones that are unused */
 	debug("clear\n");
-	for (; i < MTRR_MAX_COUNT; i++)
+	for (; i < mtrr_get_var_count(); i++)
 		wrmsrl(MTRR_PHYS_MASK_MSR(i), 0);
 	debug("close\n");
 	mtrr_close(&state, do_caches);
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 x86: Avoid using hardcoded number of variable range MTRRs in mtrr_commit()

Hi Bin,

Quoted 9 lines · Bin Meng

Since commit 29d2d64ed55f ("x86: Add support for more than 8 MTRRs"), the maximum number of variable range MTRRs was increased from 8 to 10, which caused a #GP exception during VESA video driver probe.

On the BayTrail platform there are only 8 variable range MTRRs. In mtrr_commit() it still uses MTRR_MAX_COUNT which should have been updated to use dynamically probed number.

Quoted 9 lines

This fixes the boot failure seen on Intel Minnow Max board.

Fixes 29d2d64ed55f ("x86: Add support for more than 8 MTRRs")

---

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

I don't actually see the boot failure in my lab, but this looks right to me.

Regards,
Simon

author
#2 lore raw

PATCH 1/1 x86: Avoid using hardcoded number of variable range MTRRs in mtrr_commit()

Hi Simon,

Quoted 19 lines · Simon Glass

Hi Bin,

Quoted 15 lines · Bin Meng

Since commit 29d2d64ed55f ("x86: Add support for more than 8 MTRRs"), the maximum number of variable range MTRRs was increased from 8 to 10, which caused a #GP exception during VESA video driver probe.

On the BayTrail platform there are only 8 variable range MTRRs. In mtrr_commit() it still uses MTRR_MAX_COUNT which should have been updated to use dynamically probed number.

This fixes the boot failure seen on Intel Minnow Max board.

Fixes 29d2d64ed55f ("x86: Add support for more than 8 MTRRs")

---

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

I don't actually see the boot failure in my lab, but this looks right to me.

That's weird :)

Regards,
Bin

author
#3 lore raw

PATCH 1/1 x86: Avoid using hardcoded number of variable range MTRRs in mtrr_commit()

In reply to Simon Glass
Quoted 19 lines · Simon Glass

Hi Bin,

Quoted 15 lines · Bin Meng

Since commit 29d2d64ed55f ("x86: Add support for more than 8 MTRRs"), the maximum number of variable range MTRRs was increased from 8 to 10, which caused a #GP exception during VESA video driver probe.

On the BayTrail platform there are only 8 variable range MTRRs. In mtrr_commit() it still uses MTRR_MAX_COUNT which should have been updated to use dynamically probed number.

This fixes the boot failure seen on Intel Minnow Max board.

Fixes 29d2d64ed55f ("x86: Add support for more than 8 MTRRs")

---

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

applied to u-boot-x86, thanks!