Skip to content

Commit 5f6e3b7

Browse files
yghannambp3tk0v
authored andcommitted
x86/mce/amd: Fix threshold limit reset
The MCA threshold limit must be reset after servicing the interrupt. Currently, the restart function doesn't have an explicit check for this. It makes some assumptions based on the current limit and what's in the registers. These assumptions don't always hold, so the limit won't be reset in some cases. Make the reset condition explicit. Either an interrupt/overflow has occurred or the bank is being initialized. Signed-off-by: Yazen Ghannam <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/[email protected]
1 parent d66e1e9 commit 5f6e3b7

File tree

1 file changed

+7
-8
lines changed
  • arch/x86/kernel/cpu/mce

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ static void smca_configure(unsigned int bank, unsigned int cpu)
350350

351351
struct thresh_restart {
352352
struct threshold_block *b;
353-
int reset;
354353
int set_lvt_off;
355354
int lvt_off;
356355
u16 old_limit;
@@ -432,13 +431,13 @@ static void threshold_restart_bank(void *_tr)
432431

433432
rdmsr(tr->b->address, lo, hi);
434433

435-
if (tr->b->threshold_limit < (hi & THRESHOLD_MAX))
436-
tr->reset = 1; /* limit cannot be lower than err count */
437-
438-
if (tr->reset) { /* reset err count and overflow bit */
439-
hi =
440-
(hi & ~(MASK_ERR_COUNT_HI | MASK_OVERFLOW_HI)) |
441-
(THRESHOLD_MAX - tr->b->threshold_limit);
434+
/*
435+
* Reset error count and overflow bit.
436+
* This is done during init or after handling an interrupt.
437+
*/
438+
if (hi & MASK_OVERFLOW_HI || tr->set_lvt_off) {
439+
hi &= ~(MASK_ERR_COUNT_HI | MASK_OVERFLOW_HI);
440+
hi |= THRESHOLD_MAX - tr->b->threshold_limit;
442441
} else if (tr->old_limit) { /* change limit w/o reset */
443442
int new_count = (hi & THRESHOLD_MAX) +
444443
(tr->old_limit - tr->b->threshold_limit);

0 commit comments

Comments
 (0)