Commit c9bf318f authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Borislav Petkov

x86/mce/amd: Init thresholding machinery only on relevant vendors

... and not unconditionally.

 [ bp: Add a new vendor_flags bit for that. ]
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20200403161943.1458-3-bp@alien8.de
parent ada018b1
...@@ -1442,15 +1442,20 @@ static void threshold_remove_bank(unsigned int cpu, int bank) ...@@ -1442,15 +1442,20 @@ static void threshold_remove_bank(unsigned int cpu, int bank)
int mce_threshold_remove_device(unsigned int cpu) int mce_threshold_remove_device(unsigned int cpu)
{ {
struct threshold_bank **bp = this_cpu_read(threshold_banks);
unsigned int bank; unsigned int bank;
if (!bp)
return 0;
for (bank = 0; bank < per_cpu(mce_num_banks, cpu); ++bank) { for (bank = 0; bank < per_cpu(mce_num_banks, cpu); ++bank) {
if (!(per_cpu(bank_map, cpu) & (1 << bank))) if (!(per_cpu(bank_map, cpu) & (1 << bank)))
continue; continue;
threshold_remove_bank(cpu, bank); threshold_remove_bank(cpu, bank);
} }
kfree(per_cpu(threshold_banks, cpu)); /* Clear the pointer before freeing the memory */
per_cpu(threshold_banks, cpu) = NULL; this_cpu_write(threshold_banks, NULL);
kfree(bp);
return 0; return 0;
} }
...@@ -1461,6 +1466,9 @@ int mce_threshold_create_device(unsigned int cpu) ...@@ -1461,6 +1466,9 @@ int mce_threshold_create_device(unsigned int cpu)
struct threshold_bank **bp; struct threshold_bank **bp;
int err = 0; int err = 0;
if (!mce_flags.amd_threshold)
return 0;
bp = per_cpu(threshold_banks, cpu); bp = per_cpu(threshold_banks, cpu);
if (bp) if (bp)
return 0; return 0;
......
...@@ -1756,6 +1756,7 @@ static void __mcheck_cpu_init_early(struct cpuinfo_x86 *c) ...@@ -1756,6 +1756,7 @@ static void __mcheck_cpu_init_early(struct cpuinfo_x86 *c)
mce_flags.overflow_recov = !!cpu_has(c, X86_FEATURE_OVERFLOW_RECOV); mce_flags.overflow_recov = !!cpu_has(c, X86_FEATURE_OVERFLOW_RECOV);
mce_flags.succor = !!cpu_has(c, X86_FEATURE_SUCCOR); mce_flags.succor = !!cpu_has(c, X86_FEATURE_SUCCOR);
mce_flags.smca = !!cpu_has(c, X86_FEATURE_SMCA); mce_flags.smca = !!cpu_has(c, X86_FEATURE_SMCA);
mce_flags.amd_threshold = 1;
if (mce_flags.smca) { if (mce_flags.smca) {
msr_ops.ctl = smca_ctl_reg; msr_ops.ctl = smca_ctl_reg;
......
...@@ -158,7 +158,10 @@ struct mce_vendor_flags { ...@@ -158,7 +158,10 @@ struct mce_vendor_flags {
*/ */
smca : 1, smca : 1,
__reserved_0 : 61; /* AMD-style error thresholding banks present. */
amd_threshold : 1,
__reserved_0 : 60;
}; };
extern struct mce_vendor_flags mce_flags; extern struct mce_vendor_flags mce_flags;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment