The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Tony Luck <tony.luck@intel.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Hans de Goede" <hansg@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>, Breno Leitao <leitao@debian.org>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, patches@lists.linux.dev,
	Tony Luck <tony.luck@intel.com>,
	Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Subject: [PATCH 5/7] platform/x86/intel/bff: Reset bitfix filter when it overflows
Date: Tue, 25 Aug 2026 11:15:24 -0700	[thread overview]
Message-ID: <20260825181526.13203-6-tony.luck@intel.com> (raw)
In-Reply-To: <20260825181526.13203-1-tony.luck@intel.com>

Get notifications for all errors logged in machine check banks. Skip any
that do not indicate a bitfix filter overflow.

Reset the bitfix filter using the CPU that reported the error to get
the right scoped machine check bank.

Co-developed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
 drivers/platform/x86/intel/bff.c | 41 ++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/drivers/platform/x86/intel/bff.c b/drivers/platform/x86/intel/bff.c
index 6360bbc92347..8cc29d11e019 100644
--- a/drivers/platform/x86/intel/bff.c
+++ b/drivers/platform/x86/intel/bff.c
@@ -17,11 +17,13 @@
  */
 #define pr_fmt(fmt) "bff: " fmt
 
+#include <linux/bits.h>
 #include <linux/cpufeature.h>
 #include <linux/device-id/x86_cpu.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/notifier.h>
 #include <linux/printk.h>
 #include <linux/types.h>
 
@@ -32,6 +34,11 @@
 #include <asm/msr.h>
 #include <asm/msr-index.h>
 
+/* Intel bitfix filter control register defines */
+#define MSR_MC0_BFF_CTL		0x000006c0
+#define MSR_MCx_BFF_CTL(x)	(MSR_MC0_BFF_CTL + (x))
+#define  MCI_BFF_RESET		BIT_ULL(0)
+
 /* Machine check bank scope types */
 enum bff_type {
 	BFF_NONE = 0,
@@ -60,6 +67,37 @@ MODULE_DEVICE_TABLE(x86cpu, bff_cpu_ids);
 
 static const enum bff_type *bank_types;
 
+static void handle_bff(struct mce *mce)
+{
+	/* The bitfix filter overflowed, get the target CPU to reset it. */
+	if (wrmsrq_on_cpu(mce->extcpu, MSR_MCx_BFF_CTL(mce->bank), MCI_BFF_RESET))
+		pr_warn("Failed to reset bitfix filter for CPU %d Bank %d\n", mce->extcpu, mce->bank);
+}
+
+static int bff_mce_notify(struct notifier_block *nb, unsigned long val, void *data)
+{
+	struct mce *mce = (struct mce *)data;
+
+	/* TES is undefined for uncorrected errors. */
+	if (mce->status & MCI_STATUS_UC)
+		return NOTIFY_DONE;
+
+	if (MCI_STATUS_TES(mce->status) != MCI_STATUS_TES_YELLOW)
+		return NOTIFY_DONE;
+
+	if (mce->bank >= MAX_NR_BANKS || bank_types[mce->bank] == BFF_NONE)
+		return NOTIFY_DONE;
+
+	handle_bff(mce);
+
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block bff_notifier = {
+	.notifier_call	= bff_mce_notify,
+	.priority	= MCE_PRIO_EARLY,
+};
+
 static int __init bff_init(void)
 {
 	const struct x86_cpu_id *m;
@@ -86,11 +124,14 @@ static int __init bff_init(void)
 
 	bank_types = (const enum bff_type *)m->driver_data;
 
+	mce_register_decode_chain(&bff_notifier);
+
 	return 0;
 }
 
 static void __exit bff_exit(void)
 {
+	mce_unregister_decode_chain(&bff_notifier);
 }
 
 module_init(bff_init);
-- 
2.55.0


  parent reply	other threads:[~2026-08-25 18:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 18:15 [PATCH 0/7] Intel platform driver to reset bitfix filters Tony Luck
2026-08-25 18:15 ` [PATCH 1/7] cacheinfo: Export get_cpu_cacheinfo_id() for loadable modules Tony Luck
2026-08-25 18:15 ` [PATCH 2/7] x86/mce: Enumeration updates for Intel bitfix filter reset Tony Luck
2026-08-26  8:15   ` Ilpo Järvinen
2026-08-25 18:15 ` [PATCH 3/7] platform/x86/intel/bff: Add stub Intel bitfix filter driver Tony Luck
2026-08-25 18:15 ` [PATCH 4/7] platform/x86/intel/bff: Add Diamond Rapids support Tony Luck
2026-08-26  8:17   ` Ilpo Järvinen
2026-08-25 18:15 ` Tony Luck [this message]
2026-08-25 18:15 ` [PATCH 6/7] platform/x86/intel/bff: Compute unique ID for overflowed filter Tony Luck
2026-08-26  8:26   ` Ilpo Järvinen
2026-08-25 18:15 ` [PATCH 7/7] platform/x86/intel/bff: Report frequent filter resets Tony Luck
2026-08-26  8:39   ` Ilpo Järvinen
2026-08-25 18:28 ` [PATCH 0/7] Intel platform driver to reset bitfix filters Borislav Petkov
2026-08-25 18:55   ` Luck, Tony
2026-08-25 19:23     ` Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260825181526.13203-6-tony.luck@intel.com \
    --to=tony.luck@intel.com \
    --cc=bp@alien8.de \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=qiuxu.zhuo@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox