Skip to content

Commit 919f18f

Browse files
Andi KleenKAGA-KOKO
authored andcommitted
x86/mtrr: Check if fixed MTRRs exist before saving them
MTRRs have an obsolete fixed variant for fine grained caching control of the 640K-1MB region that uses separate MSRs. This fixed variant has a separate capability bit in the MTRR capability MSR. So far all x86 CPUs which support MTRR have this separate bit set, so it went unnoticed that mtrr_save_state() does not check the capability bit before accessing the fixed MTRR MSRs. Though on a CPU that does not support the fixed MTRR capability this results in a #GP. The #GP itself is harmless because the RDMSR fault is handled gracefully, but results in a WARN_ON(). Add the missing capability check to prevent this. Fixes: 2b1f627 ("[PATCH] x86: Save the MTRRs of the BSP before booting an AP") Signed-off-by: Andi Kleen <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/all/[email protected]
1 parent e639222 commit 919f18f

File tree

1 file changed

+1
-1
lines changed
  • arch/x86/kernel/cpu/mtrr

1 file changed

+1
-1
lines changed

arch/x86/kernel/cpu/mtrr/mtrr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ void mtrr_save_state(void)
609609
{
610610
int first_cpu;
611611

612-
if (!mtrr_enabled())
612+
if (!mtrr_enabled() || !mtrr_state.have_fixed)
613613
return;
614614

615615
first_cpu = cpumask_first(cpu_online_mask);

0 commit comments

Comments
 (0)