[PATCH 5/7] platform/x86/intel/bff: Reset bitfix filter when it overflows

From: Tony Luck

Date: Tue Aug 25 2026 - 14:17:32 EST


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@xxxxxxxxx>
Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@xxxxxxxxx>
Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
---
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