]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
x86/mce: Add a clear_bank() helper
authorYazen Ghannam <yazen.ghannam@amd.com>
Mon, 8 Sep 2025 15:40:36 +0000 (15:40 +0000)
committerBorislav Petkov (AMD) <bp@alien8.de>
Thu, 11 Sep 2025 10:23:30 +0000 (12:23 +0200)
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
arch/x86/kernel/cpu/mce/amd.c
arch/x86/kernel/cpu/mce/core.c
arch/x86/kernel/cpu/mce/internal.h

index b8aed0ac765c913b5696e6a2456ff25a7a7bbfe1..d6906442f49bf98bff1b652671806114ec5ea511 100644 (file)
@@ -955,6 +955,11 @@ static void amd_threshold_interrupt(void)
        }
 }
 
+void amd_clear_bank(struct mce *m)
+{
+       mce_wrmsrq(mca_msr_reg(m->bank, MCA_STATUS), 0);
+}
+
 /*
  * Sysfs Interface
  */
index 5dec0da6169e60f6d7ee5e2f6a7888b224e6cbe9..460e90a1a0b172d2b8b88e3635922c637b6e684a 100644 (file)
@@ -423,7 +423,7 @@ noinstr u64 mce_rdmsrq(u32 msr)
        return EAX_EDX_VAL(val, low, high);
 }
 
-static noinstr void mce_wrmsrq(u32 msr, u64 v)
+noinstr void mce_wrmsrq(u32 msr, u64 v)
 {
        u32 low, high;
 
@@ -760,6 +760,14 @@ static bool should_log_poll_error(enum mcp_flags flags, struct mce_hw_err *err)
        return true;
 }
 
+static void clear_bank(struct mce *m)
+{
+       if (m->cpuvendor == X86_VENDOR_AMD)
+               return amd_clear_bank(m);
+
+       mce_wrmsrq(mca_msr_reg(m->bank, MCA_STATUS), 0);
+}
+
 /*
  * Poll for corrected events or events that happened before reset.
  * Those are just logged through /dev/mcelog.
@@ -831,10 +839,7 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b)
                        mce_log(&err);
 
 clear_it:
-               /*
-                * Clear state for this bank.
-                */
-               mce_wrmsrq(mca_msr_reg(i, MCA_STATUS), 0);
+               clear_bank(m);
        }
 
        /*
index 6cb2995f0ec1d74e51da77c7395ad2de221c55cf..b0e00ec5cc8c9f5c8a3452490182879de5e89774 100644 (file)
@@ -269,6 +269,7 @@ void mce_threshold_create_device(unsigned int cpu);
 void mce_threshold_remove_device(unsigned int cpu);
 extern bool amd_filter_mce(struct mce *m);
 bool amd_mce_usable_address(struct mce *m);
+void amd_clear_bank(struct mce *m);
 
 /*
  * If MCA_CONFIG[McaLsbInStatusSupported] is set, extract ErrAddr in bits
@@ -300,6 +301,7 @@ static inline void mce_threshold_create_device(unsigned int cpu)    { }
 static inline void mce_threshold_remove_device(unsigned int cpu)       { }
 static inline bool amd_filter_mce(struct mce *m) { return false; }
 static inline bool amd_mce_usable_address(struct mce *m) { return false; }
+static inline void amd_clear_bank(struct mce *m) { }
 static inline void smca_extract_err_addr(struct mce *m) { }
 static inline void smca_bsp_init(void) { }
 #endif
@@ -319,6 +321,7 @@ static __always_inline void winchip_machine_check(struct pt_regs *regs) {}
 #endif
 
 noinstr u64 mce_rdmsrq(u32 msr);
+noinstr void mce_wrmsrq(u32 msr, u64 v);
 
 static __always_inline u32 mca_msr_reg(int bank, enum mca_msr reg)
 {