[C] [PATCH 3/4] x86/MCE: Add an MCE-record filtering function

Kai-Heng Feng kai.heng.feng at canonical.com
Wed Jul 3 07:23:08 UTC 2019


From: Yazen Ghannam <yazen.ghannam at amd.com>

BugLink: https://bugs.launchpad.net/bugs/1796443

Some systems may report spurious MCA errors. In general, spurious MCA
errors may be disabled by clearing a particular bit in MCA_CTL. However,
clearing a bit in MCA_CTL may not be recommended for some errors, so the
only option is to ignore them.

An MCA error is printed and handled after it has been added to the MCE
event pool. So an MCA error can be ignored by not adding it to that pool
in the first place.

Add such a filtering function.

 [ bp: Move function prototype to the internal header and massage. ]

Signed-off-by: Yazen Ghannam <yazen.ghannam at amd.com>
Signed-off-by: Borislav Petkov <bp at suse.de>
Cc: Arnd Bergmann <arnd at arndb.de>
Cc: "clemej at gmail.com" <clemej at gmail.com>
Cc: "H. Peter Anvin" <hpa at zytor.com>
Cc: Ingo Molnar <mingo at redhat.com>
Cc: Pu Wen <puwen at hygon.cn>
Cc: Qiuxu Zhuo <qiuxu.zhuo at intel.com>
Cc: "rafal at milecki.pl" <rafal at milecki.pl>
Cc: Shirish S <Shirish.S at amd.com>
Cc: <stable at vger.kernel.org> # 5.0.x
Cc: Thomas Gleixner <tglx at linutronix.de>
Cc: Tony Luck <tony.luck at intel.com>
Cc: Vishal Verma <vishal.l.verma at intel.com>
Cc: x86-ml <x86 at kernel.org>
Link: https://lkml.kernel.org/r/20190325163410.171021-1-Yazen.Ghannam@amd.com
(backported from commit 45d4b7b9cb88526f6d5bd4c03efab88d75d10e4f)
Signed-off-by: Kai-Heng Feng <kai.heng.feng at canonical.com>
---
 arch/x86/kernel/cpu/mcheck/mce-genpool.c  | 3 +++
 arch/x86/kernel/cpu/mcheck/mce-internal.h | 3 +++
 arch/x86/kernel/cpu/mcheck/mce.c          | 5 +++++
 3 files changed, 11 insertions(+)

diff --git a/arch/x86/kernel/cpu/mcheck/mce-genpool.c b/arch/x86/kernel/cpu/mcheck/mce-genpool.c
index 217cd4449bc9..fe1e74d0fb5b 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-genpool.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-genpool.c
@@ -99,6 +99,9 @@ int mce_gen_pool_add(struct mce *mce)
 {
 	struct mce_evt_llist *node;
 
+	if (filter_mce(mce))
+		return -EINVAL;
+
 	if (!mce_evt_pool)
 		return -EINVAL;
 
diff --git a/arch/x86/kernel/cpu/mcheck/mce-internal.h b/arch/x86/kernel/cpu/mcheck/mce-internal.h
index ceb67cd5918f..e48fefda6c68 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-internal.h
+++ b/arch/x86/kernel/cpu/mcheck/mce-internal.h
@@ -170,4 +170,7 @@ struct mca_msr_regs {
 
 extern struct mca_msr_regs msr_ops;
 
+/* Decide whether to add MCE record to MCE event pool or filter it out. */
+extern bool filter_mce(struct mce *m);
+
 #endif /* __X86_MCE_INTERNAL_H__ */
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 7a7b3a95b4ba..bd0e3c3da8bc 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1752,6 +1752,11 @@ static void __mcheck_cpu_init_timer(void)
 	mce_start_timer(t);
 }
 
+bool filter_mce(struct mce *m)
+{
+	return false;
+}
+
 /* Handle unconfigured int18 (should never happen) */
 static void unexpected_machine_check(struct pt_regs *regs, long error_code)
 {
-- 
2.17.1




More information about the kernel-team mailing list