Skip to content

Commit cfffcf9

Browse files
yghannambp3tk0v
authored andcommitted
x86/mce: Set CR4.MCE last during init
Set the CR4.MCE bit as the last step during init. This brings the MCA init order closer to what is described in the x86 docs. x86 docs: AMD Intel MCG_CTL MCA_CONFIG MCG_EXT_CTL MCi_CTL MCi_CTL MCG_CTL CR4.MCE CR4.MCE Current Linux: AMD Intel CR4.MCE CR4.MCE MCG_CTL MCG_CTL MCA_CONFIG MCG_EXT_CTL MCi_CTL MCi_CTL Updated Linux: AMD Intel MCG_CTL MCG_CTL MCA_CONFIG MCG_EXT_CTL MCi_CTL MCi_CTL CR4.MCE CR4.MCE The new init flow will match Intel's docs, but there will still be a mismatch for AMD regarding MCG_CTL. However, there is no known issue with this ordering, so leave it for now. Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Nikolay Borisov <nik.borisov@suse.com> Link: https://lore.kernel.org/20250908-wip-mca-updates-v6-0-eef5d6c74b9c@amd.com
1 parent 9f34032 commit cfffcf9

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

arch/x86/kernel/cpu/mce/core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,8 +1850,6 @@ static void __mcheck_cpu_init_generic(void)
18501850
{
18511851
u64 cap;
18521852

1853-
cr4_set_bits(X86_CR4_MCE);
1854-
18551853
rdmsrq(MSR_IA32_MCG_CAP, cap);
18561854
if (cap & MCG_CTL_P)
18571855
wrmsr(MSR_IA32_MCG_CTL, 0xffffffff, 0xffffffff);
@@ -2276,6 +2274,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
22762274
__mcheck_cpu_init_vendor(c);
22772275
__mcheck_cpu_init_prepare_banks();
22782276
__mcheck_cpu_setup_timer();
2277+
cr4_set_bits(X86_CR4_MCE);
22792278
}
22802279

22812280
/*
@@ -2443,6 +2442,7 @@ static void mce_syscore_resume(void)
24432442
__mcheck_cpu_init_generic();
24442443
__mcheck_cpu_init_vendor(raw_cpu_ptr(&cpu_info));
24452444
__mcheck_cpu_init_prepare_banks();
2445+
cr4_set_bits(X86_CR4_MCE);
24462446
}
24472447

24482448
static struct syscore_ops mce_syscore_ops = {
@@ -2462,6 +2462,7 @@ static void mce_cpu_restart(void *data)
24622462
__mcheck_cpu_init_generic();
24632463
__mcheck_cpu_init_prepare_banks();
24642464
__mcheck_cpu_init_timer();
2465+
cr4_set_bits(X86_CR4_MCE);
24652466
}
24662467

24672468
/* Reinit MCEs after user configuration changes */

0 commit comments

Comments
 (0)