Skip to content

Commit 495a91d

Browse files
yghannambp3tk0v
authored andcommitted
x86/MCE/AMD: Split amd_mce_is_memory_error()
Define helper functions for legacy and SMCA systems in order to reuse individual checks in later changes. Describe what each function is checking for, and correct the XEC bitmask for SMCA. No functional change intended. [ bp: Use "else in amd_mce_is_memory_error() to make the conditional balanced, for readability. ] Signed-off-by: Yazen Ghannam <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Shuai Xue <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5872080 commit 495a91d

File tree

1 file changed

+26
-6
lines changed
  • arch/x86/kernel/cpu/mce

1 file changed

+26
-6
lines changed

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,17 +713,37 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c)
713713
deferred_error_interrupt_enable(c);
714714
}
715715

716-
bool amd_mce_is_memory_error(struct mce *m)
716+
/*
717+
* DRAM ECC errors are reported in the Northbridge (bank 4) with
718+
* Extended Error Code 8.
719+
*/
720+
static bool legacy_mce_is_memory_error(struct mce *m)
721+
{
722+
return m->bank == 4 && XEC(m->status, 0x1f) == 8;
723+
}
724+
725+
/*
726+
* DRAM ECC errors are reported in Unified Memory Controllers with
727+
* Extended Error Code 0.
728+
*/
729+
static bool smca_mce_is_memory_error(struct mce *m)
717730
{
718731
enum smca_bank_types bank_type;
719-
/* ErrCodeExt[20:16] */
720-
u8 xec = (m->status >> 16) & 0x1f;
732+
733+
if (XEC(m->status, 0x3f))
734+
return false;
721735

722736
bank_type = smca_get_bank_type(m->extcpu, m->bank);
723-
if (mce_flags.smca)
724-
return (bank_type == SMCA_UMC || bank_type == SMCA_UMC_V2) && xec == 0x0;
725737

726-
return m->bank == 4 && xec == 0x8;
738+
return bank_type == SMCA_UMC || bank_type == SMCA_UMC_V2;
739+
}
740+
741+
bool amd_mce_is_memory_error(struct mce *m)
742+
{
743+
if (mce_flags.smca)
744+
return smca_mce_is_memory_error(m);
745+
else
746+
return legacy_mce_is_memory_error(m);
727747
}
728748

729749
static void __log_error(unsigned int bank, u64 status, u64 addr, u64 misc)

0 commit comments

Comments
 (0)