From: Bin Meng Date: Mon, 9 Nov 2020 07:55:49 +0000 (+0800) Subject: x86: Avoid using hardcoded number of variable range MTRRs in mtrr_commit() X-Git-Tag: v2025.01-rc5-pxa1908~2130^2~2 X-Git-Url: http://git.dujemihanovic.xyz/%7B%7B%20%24style.Permalink%20%7D%7D?a=commitdiff_plain;h=f72d3d6b04d21a7b2ba7ba9ee551dd6f1a9b93e4;p=u-boot.git 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. On the BayTrail platform there are only 8 variable range MTRRs. In mtrr_commit() it still uses MTRR_MAX_COUNT which caused a #GP during VESA video driver probe. It 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") Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- diff --git a/arch/x86/cpu/mtrr.c b/arch/x86/cpu/mtrr.c index 5180eb06fc..6f095c53a5 100644 --- a/arch/x86/cpu/mtrr.c +++ b/arch/x86/cpu/mtrr.c @@ -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);