Skip to content

Commit c9bf318

Browse files
KAGA-KOKOsuryasaimadhu
authored andcommitted
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: Thomas Gleixner <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent ada018b commit c9bf318

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,15 +1442,20 @@ static void threshold_remove_bank(unsigned int cpu, int bank)
14421442

14431443
int mce_threshold_remove_device(unsigned int cpu)
14441444
{
1445+
struct threshold_bank **bp = this_cpu_read(threshold_banks);
14451446
unsigned int bank;
14461447

1448+
if (!bp)
1449+
return 0;
1450+
14471451
for (bank = 0; bank < per_cpu(mce_num_banks, cpu); ++bank) {
14481452
if (!(per_cpu(bank_map, cpu) & (1 << bank)))
14491453
continue;
14501454
threshold_remove_bank(cpu, bank);
14511455
}
1452-
kfree(per_cpu(threshold_banks, cpu));
1453-
per_cpu(threshold_banks, cpu) = NULL;
1456+
/* Clear the pointer before freeing the memory */
1457+
this_cpu_write(threshold_banks, NULL);
1458+
kfree(bp);
14541459
return 0;
14551460
}
14561461

@@ -1461,6 +1466,9 @@ int mce_threshold_create_device(unsigned int cpu)
14611466
struct threshold_bank **bp;
14621467
int err = 0;
14631468

1469+
if (!mce_flags.amd_threshold)
1470+
return 0;
1471+
14641472
bp = per_cpu(threshold_banks, cpu);
14651473
if (bp)
14661474
return 0;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,7 @@ static void __mcheck_cpu_init_early(struct cpuinfo_x86 *c)
17561756
mce_flags.overflow_recov = !!cpu_has(c, X86_FEATURE_OVERFLOW_RECOV);
17571757
mce_flags.succor = !!cpu_has(c, X86_FEATURE_SUCCOR);
17581758
mce_flags.smca = !!cpu_has(c, X86_FEATURE_SMCA);
1759+
mce_flags.amd_threshold = 1;
17591760

17601761
if (mce_flags.smca) {
17611762
msr_ops.ctl = smca_ctl_reg;

arch/x86/kernel/cpu/mce/internal.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,20 @@ struct mce_vendor_flags {
148148
* Recovery. It indicates support for data poisoning in HW and deferred
149149
* error interrupts.
150150
*/
151-
succor : 1,
151+
succor : 1,
152152

153153
/*
154154
* (AMD) SMCA: This bit indicates support for Scalable MCA which expands
155155
* the register space for each MCA bank and also increases number of
156156
* banks. Also, to accommodate the new banks and registers, the MCA
157157
* register space is moved to a new MSR range.
158158
*/
159-
smca : 1,
159+
smca : 1,
160160

161-
__reserved_0 : 61;
161+
/* AMD-style error thresholding banks present. */
162+
amd_threshold : 1,
163+
164+
__reserved_0 : 60;
162165
};
163166

164167
extern struct mce_vendor_flags mce_flags;

0 commit comments

Comments
 (0)