Skip to content

Commit a037f3c

Browse files
KAGA-KOKOsuryasaimadhu
authored andcommitted
x86/mce/amd: Make threshold bank setting hotplug robust
Handle the cases when the CPU goes offline before the bank setting/reading happens. [ bp: Write commit message. ] Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent f26d258 commit a037f3c

File tree

1 file changed

+11
-3
lines changed
  • arch/x86/kernel/cpu/mce

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ static void threshold_restart_bank(void *_tr)
386386
struct thresh_restart *tr = _tr;
387387
u32 hi, lo;
388388

389+
/* sysfs write might race against an offline operation */
390+
if (this_cpu_read(threshold_banks))
391+
return;
392+
389393
rdmsr(tr->b->address, lo, hi);
390394

391395
if (tr->b->threshold_limit < (hi & THRESHOLD_MAX))
@@ -1085,7 +1089,8 @@ store_interrupt_enable(struct threshold_block *b, const char *buf, size_t size)
10851089
memset(&tr, 0, sizeof(tr));
10861090
tr.b = b;
10871091

1088-
smp_call_function_single(b->cpu, threshold_restart_bank, &tr, 1);
1092+
if (smp_call_function_single(b->cpu, threshold_restart_bank, &tr, 1))
1093+
return -ENODEV;
10891094

10901095
return size;
10911096
}
@@ -1109,7 +1114,8 @@ store_threshold_limit(struct threshold_block *b, const char *buf, size_t size)
11091114
b->threshold_limit = new;
11101115
tr.b = b;
11111116

1112-
smp_call_function_single(b->cpu, threshold_restart_bank, &tr, 1);
1117+
if (smp_call_function_single(b->cpu, threshold_restart_bank, &tr, 1))
1118+
return -ENODEV;
11131119

11141120
return size;
11151121
}
@@ -1118,7 +1124,9 @@ static ssize_t show_error_count(struct threshold_block *b, char *buf)
11181124
{
11191125
u32 lo, hi;
11201126

1121-
rdmsr_on_cpu(b->cpu, b->address, &lo, &hi);
1127+
/* CPU might be offline by now */
1128+
if (rdmsr_on_cpu(b->cpu, b->address, &lo, &hi))
1129+
return -ENODEV;
11221130

11231131
return sprintf(buf, "%u\n", ((hi & THRESHOLD_MAX) -
11241132
(THRESHOLD_MAX - b->threshold_limit)));

0 commit comments

Comments
 (0)