Skip to content

Commit 5c6f123

Browse files
yghannambp3tk0v
authored andcommitted
x86/mce: Add a clear_bank() helper
Add a helper at the end of the MCA polling function to collect vendor and/or feature actions. Start with a basic skeleton for now. Actions for AMD thresholding and deferred errors will be added later. [ bp: Drop the obvious comment too. ] Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Nikolay Borisov <nik.borisov@suse.com> Link: https://lore.kernel.org/20250908-wip-mca-updates-v6-0-eef5d6c74b9c@amd.com
1 parent 91af684 commit 5c6f123

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,11 @@ static void amd_threshold_interrupt(void)
955955
}
956956
}
957957

958+
void amd_clear_bank(struct mce *m)
959+
{
960+
mce_wrmsrq(mca_msr_reg(m->bank, MCA_STATUS), 0);
961+
}
962+
958963
/*
959964
* Sysfs Interface
960965
*/

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ noinstr u64 mce_rdmsrq(u32 msr)
423423
return EAX_EDX_VAL(val, low, high);
424424
}
425425

426-
static noinstr void mce_wrmsrq(u32 msr, u64 v)
426+
noinstr void mce_wrmsrq(u32 msr, u64 v)
427427
{
428428
u32 low, high;
429429

@@ -760,6 +760,14 @@ static bool should_log_poll_error(enum mcp_flags flags, struct mce_hw_err *err)
760760
return true;
761761
}
762762

763+
static void clear_bank(struct mce *m)
764+
{
765+
if (m->cpuvendor == X86_VENDOR_AMD)
766+
return amd_clear_bank(m);
767+
768+
mce_wrmsrq(mca_msr_reg(m->bank, MCA_STATUS), 0);
769+
}
770+
763771
/*
764772
* Poll for corrected events or events that happened before reset.
765773
* Those are just logged through /dev/mcelog.
@@ -831,10 +839,7 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b)
831839
mce_log(&err);
832840

833841
clear_it:
834-
/*
835-
* Clear state for this bank.
836-
*/
837-
mce_wrmsrq(mca_msr_reg(i, MCA_STATUS), 0);
842+
clear_bank(m);
838843
}
839844

840845
/*

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ void mce_threshold_create_device(unsigned int cpu);
269269
void mce_threshold_remove_device(unsigned int cpu);
270270
extern bool amd_filter_mce(struct mce *m);
271271
bool amd_mce_usable_address(struct mce *m);
272+
void amd_clear_bank(struct mce *m);
272273

273274
/*
274275
* If MCA_CONFIG[McaLsbInStatusSupported] is set, extract ErrAddr in bits
@@ -300,6 +301,7 @@ static inline void mce_threshold_create_device(unsigned int cpu) { }
300301
static inline void mce_threshold_remove_device(unsigned int cpu) { }
301302
static inline bool amd_filter_mce(struct mce *m) { return false; }
302303
static inline bool amd_mce_usable_address(struct mce *m) { return false; }
304+
static inline void amd_clear_bank(struct mce *m) { }
303305
static inline void smca_extract_err_addr(struct mce *m) { }
304306
static inline void smca_bsp_init(void) { }
305307
#endif
@@ -319,6 +321,7 @@ static __always_inline void winchip_machine_check(struct pt_regs *regs) {}
319321
#endif
320322

321323
noinstr u64 mce_rdmsrq(u32 msr);
324+
noinstr void mce_wrmsrq(u32 msr, u64 v);
322325

323326
static __always_inline u32 mca_msr_reg(int bank, enum mca_msr reg)
324327
{

0 commit comments

Comments
 (0)