Skip to content

Commit bc1b705

Browse files
yghannamsuryasaimadhu
authored andcommitted
x86/MCE/AMD: Clear DFR errors found in THR handler
AMD's MCA Thresholding feature counts errors of all severity levels, not just correctable errors. If a deferred error causes the threshold limit to be reached (it was the error that caused the overflow), then both a deferred error interrupt and a thresholding interrupt will be triggered. The order of the interrupts is not guaranteed. If the threshold interrupt handler is executed first, then it will clear MCA_STATUS for the error. It will not check or clear MCA_DESTAT which also holds a copy of the deferred error. When the deferred error interrupt handler runs it will not find an error in MCA_STATUS, but it will find the error in MCA_DESTAT. This will cause two errors to be logged. Check for deferred errors when handling a threshold interrupt. If a bank contains a deferred error, then clear the bank's MCA_DESTAT register. Define a new helper function to do the deferred error check and clearing of MCA_DESTAT. [ bp: Simplify, convert comment to passive voice. ] Fixes: 37d43ac ("x86/mce/AMD: Redo error logging from APIC LVT interrupt handlers") Signed-off-by: Yazen Ghannam <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent 9abf231 commit bc1b705

File tree

1 file changed

+20
-13
lines changed
  • arch/x86/kernel/cpu/mce

1 file changed

+20
-13
lines changed

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

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,24 @@ _log_error_bank(unsigned int bank, u32 msr_stat, u32 msr_addr, u64 misc)
788788
return status & MCI_STATUS_DEFERRED;
789789
}
790790

791+
static bool _log_error_deferred(unsigned int bank, u32 misc)
792+
{
793+
if (!_log_error_bank(bank, mca_msr_reg(bank, MCA_STATUS),
794+
mca_msr_reg(bank, MCA_ADDR), misc))
795+
return false;
796+
797+
/*
798+
* Non-SMCA systems don't have MCA_DESTAT/MCA_DEADDR registers.
799+
* Return true here to avoid accessing these registers.
800+
*/
801+
if (!mce_flags.smca)
802+
return true;
803+
804+
/* Clear MCA_DESTAT if the deferred error was logged from MCA_STATUS. */
805+
wrmsrl(MSR_AMD64_SMCA_MCx_DESTAT(bank), 0);
806+
return true;
807+
}
808+
791809
/*
792810
* We have three scenarios for checking for Deferred errors:
793811
*
@@ -799,19 +817,8 @@ _log_error_bank(unsigned int bank, u32 msr_stat, u32 msr_addr, u64 misc)
799817
*/
800818
static void log_error_deferred(unsigned int bank)
801819
{
802-
bool defrd;
803-
804-
defrd = _log_error_bank(bank, mca_msr_reg(bank, MCA_STATUS),
805-
mca_msr_reg(bank, MCA_ADDR), 0);
806-
807-
if (!mce_flags.smca)
808-
return;
809-
810-
/* Clear MCA_DESTAT if we logged the deferred error from MCA_STATUS. */
811-
if (defrd) {
812-
wrmsrl(MSR_AMD64_SMCA_MCx_DESTAT(bank), 0);
820+
if (_log_error_deferred(bank, 0))
813821
return;
814-
}
815822

816823
/*
817824
* Only deferred errors are logged in MCA_DE{STAT,ADDR} so just check
@@ -832,7 +839,7 @@ static void amd_deferred_error_interrupt(void)
832839

833840
static void log_error_thresholding(unsigned int bank, u64 misc)
834841
{
835-
_log_error_bank(bank, mca_msr_reg(bank, MCA_STATUS), mca_msr_reg(bank, MCA_ADDR), misc);
842+
_log_error_deferred(bank, misc);
836843
}
837844

838845
static void log_and_reset_block(struct threshold_block *block)

0 commit comments

Comments
 (0)