[PATCH 3/6] x86-mce: Clear CMCI enable on all claimed CMCI banks before reboot.

From: Havard Skinnemoen
Date: Wed Jul 09 2014 - 13:09:51 EST


From: Ewout van Bekkum <ewout@xxxxxxxxxx>

The existing CMCI code did not call cmci_clear() on each CPU upon
reboot. This meant that a kexec would leave all the CMCI banks
unclaimable and with polling disabled as the cmci_discover() method
relies on the CMCI enable bit for each bank to determine if they can be
claimed.

Signed-off-by: Ewout van Bekkum <ewout@xxxxxxxxxx>
Signed-off-by: Havard Skinnemoen <hskinnemoen@xxxxxxxxxx>
---
arch/x86/kernel/cpu/mcheck/mce_intel.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

diff --git a/arch/x86/kernel/cpu/mcheck/mce_intel.c b/arch/x86/kernel/cpu/mcheck/mce_intel.c
index d015daf..36a1948 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_intel.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_intel.c
@@ -14,6 +14,8 @@
#include <asm/processor.h>
#include <asm/msr.h>
#include <asm/mce.h>
+#include <linux/reboot.h>
+#include <linux/atomic.h>

#include "mce-internal.h"

@@ -388,6 +390,31 @@ void cmci_disable_bank(int bank)
spin_unlock_irqrestore(&cmci_discover_lock, flags);
}

+/*
+ * Fully disable CMCI on this CPU in case of shutdown.
+ */
+static void cmci_disable(void *dummy)
+{
+ cmci_clear();
+}
+
+static int cmci_reboot_event(struct notifier_block *this,
+ unsigned long event, void *ptr)
+{
+ /*
+ * Disable CMCI on this CPU for all banks it owns so CPUs after the
+ * reboot can reclaim the banks through rediscovery.
+ */
+ on_each_cpu(cmci_disable, NULL, 1);
+ return NOTIFY_OK;
+}
+
+static struct notifier_block cmci_reboot_notifier = {
+ .notifier_call = cmci_reboot_event,
+};
+
+static bool reboot_notifier_registered;
+
static void intel_init_cmci(void)
{
int banks;
@@ -395,6 +422,9 @@ static void intel_init_cmci(void)
if (!cmci_supported(&banks))
return;

+ if (!xchg(&reboot_notifier_registered, true))
+ register_reboot_notifier(&cmci_reboot_notifier);
+
mce_threshold_vector = intel_threshold_interrupt;
cmci_discover(banks);
/*
--
2.0.0.526.g5318336

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/