Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1206709
| From | tip-bot for Ashok Raj <tipbot@zytor.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [tip:ras/core] x86/mce: Clear Local MCE opt-in before kexec |
| Date | 2015-08-13 12:50 +0200 |
| Message-ID | <pWYf9-St-35@gated-at.bofh.it> (permalink) |
| References | <pWHej-1sf-15@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Commit-ID: 8838eb6c0bf3b6a6494a163947ab3d1700ab45d2
Gitweb: http://git.kernel.org/tip/8838eb6c0bf3b6a6494a163947ab3d1700ab45d2
Author: Ashok Raj <ashok.raj@intel.com>
AuthorDate: Wed, 12 Aug 2015 18:29:40 +0200
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 13 Aug 2015 10:12:52 +0200
x86/mce: Clear Local MCE opt-in before kexec
kexec could boot a kernel that could be legacy with no knowledge
of LMCE. Hence we should make sure we clear LMCE optin before
kexec reboot.
Signed-off-by: Ashok Raj <ashok.raj@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Link: http://lkml.kernel.org/r/1439396985-12812-9-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/include/asm/mce.h | 4 ++++
arch/x86/kernel/cpu/mcheck/mce.c | 30 ++++++++++++++++++++++++++++++
arch/x86/kernel/cpu/mcheck/mce_intel.c | 19 ++++++++++++++++++-
arch/x86/kernel/process.c | 2 ++
arch/x86/kernel/smp.c | 2 ++
5 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index 38d3a1a8..2dbc0bf 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -151,10 +151,12 @@ extern int mce_p5_enabled;
#ifdef CONFIG_X86_MCE
int mcheck_init(void);
void mcheck_cpu_init(struct cpuinfo_x86 *c);
+void mcheck_cpu_clear(struct cpuinfo_x86 *c);
void mcheck_vendor_init_severity(void);
#else
static inline int mcheck_init(void) { return 0; }
static inline void mcheck_cpu_init(struct cpuinfo_x86 *c) {}
+static inline void mcheck_cpu_clear(struct cpuinfo_x86 *c) {}
static inline void mcheck_vendor_init_severity(void) {}
#endif
@@ -181,12 +183,14 @@ DECLARE_PER_CPU(struct device *, mce_device);
#ifdef CONFIG_X86_MCE_INTEL
void mce_intel_feature_init(struct cpuinfo_x86 *c);
+void mce_intel_feature_clear(struct cpuinfo_x86 *c);
void cmci_clear(void);
void cmci_reenable(void);
void cmci_rediscover(void);
void cmci_recheck(void);
#else
static inline void mce_intel_feature_init(struct cpuinfo_x86 *c) { }
+static inline void mce_intel_feature_clear(struct cpuinfo_x86 *c) { }
static inline void cmci_clear(void) {}
static inline void cmci_reenable(void) {}
static inline void cmci_rediscover(void) {}
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 32b586e..ee5272d 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1606,6 +1606,17 @@ static void __mcheck_cpu_init_vendor(struct cpuinfo_x86 *c)
}
}
+static void __mcheck_cpu_clear_vendor(struct cpuinfo_x86 *c)
+{
+ switch (c->x86_vendor) {
+ case X86_VENDOR_INTEL:
+ mce_intel_feature_clear(c);
+ break;
+ default:
+ break;
+ }
+}
+
static void mce_start_timer(unsigned int cpu, struct timer_list *t)
{
unsigned long iv = check_interval * HZ;
@@ -1673,6 +1684,25 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
}
/*
+ * Called for each booted CPU to clear some machine checks opt-ins
+ */
+void mcheck_cpu_clear(struct cpuinfo_x86 *c)
+{
+ if (mca_cfg.disabled)
+ return;
+
+ if (!mce_available(c))
+ return;
+
+ /*
+ * Possibly to clear general settings generic to x86
+ * __mcheck_cpu_clear_generic(c);
+ */
+ __mcheck_cpu_clear_vendor(c);
+
+}
+
+/*
* mce_chrdev: Character device /dev/mcelog to read and clear the MCE log.
*/
diff --git a/arch/x86/kernel/cpu/mcheck/mce_intel.c b/arch/x86/kernel/cpu/mcheck/mce_intel.c
index 70f567f..c5c0032 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_intel.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_intel.c
@@ -434,7 +434,7 @@ static void intel_init_cmci(void)
cmci_recheck();
}
-void intel_init_lmce(void)
+static void intel_init_lmce(void)
{
u64 val;
@@ -447,9 +447,26 @@ void intel_init_lmce(void)
wrmsrl(MSR_IA32_MCG_EXT_CTL, val | MCG_EXT_CTL_LMCE_EN);
}
+static void intel_clear_lmce(void)
+{
+ u64 val;
+
+ if (!lmce_supported())
+ return;
+
+ rdmsrl(MSR_IA32_MCG_EXT_CTL, val);
+ val &= ~MCG_EXT_CTL_LMCE_EN;
+ wrmsrl(MSR_IA32_MCG_EXT_CTL, val);
+}
+
void mce_intel_feature_init(struct cpuinfo_x86 *c)
{
intel_init_thermal(c);
intel_init_cmci();
intel_init_lmce();
}
+
+void mce_intel_feature_clear(struct cpuinfo_x86 *c)
+{
+ intel_clear_lmce();
+}
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 397688b..b20ef18 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -29,6 +29,7 @@
#include <asm/debugreg.h>
#include <asm/nmi.h>
#include <asm/tlbflush.h>
+#include <asm/mce.h>
/*
* per-CPU TSS segments. Threads are completely 'soft' on Linux,
@@ -319,6 +320,7 @@ void stop_this_cpu(void *dummy)
*/
set_cpu_online(smp_processor_id(), false);
disable_local_APIC();
+ mcheck_cpu_clear(this_cpu_ptr(&cpu_info));
for (;;)
halt();
diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
index 15aaa69..12c8286 100644
--- a/arch/x86/kernel/smp.c
+++ b/arch/x86/kernel/smp.c
@@ -30,6 +30,7 @@
#include <asm/proto.h>
#include <asm/apic.h>
#include <asm/nmi.h>
+#include <asm/mce.h>
#include <asm/trace/irq_vectors.h>
/*
* Some notes on x86 processor bugs affecting SMP operation:
@@ -243,6 +244,7 @@ static void native_stop_other_cpus(int wait)
finish:
local_irq_save(flags);
disable_local_APIC();
+ mcheck_cpu_clear(this_cpu_ptr(&cpu_info));
local_irq_restore(flags);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/13] x86/RAS queue for 4.3 Borislav Petkov <bp@alien8.de> - 2015-08-12 18:40 +0200
[PATCH 07/13] x86/mce: Remove unused function declarations Borislav Petkov <bp@alien8.de> - 2015-08-12 18:40 +0200
[tip:ras/core] x86/mce: Remove unused function declarations tip-bot for Ashok Raj <tipbot@zytor.com> - 2015-08-13 12:50 +0200
[PATCH 05/13] x86/mce: Avoid potential deadlock due to printk() in MCE context Borislav Petkov <bp@alien8.de> - 2015-08-12 18:40 +0200
[tip:ras/core] x86/mce: Avoid potential deadlock due to printk() in MCE context "tip-bot for Chen, Gong" <tipbot@zytor.com> - 2015-08-13 12:50 +0200
[PATCH 08/13] x86/mce: Clear Local MCE opt-in before kexec Borislav Petkov <bp@alien8.de> - 2015-08-12 18:40 +0200
[tip:ras/core] x86/mce: Clear Local MCE opt-in before kexec tip-bot for Ashok Raj <tipbot@zytor.com> - 2015-08-13 12:50 +0200
[PATCH 12/13] x86/mce: Add a wrapper around mce_log() for injection Borislav Petkov <bp@alien8.de> - 2015-08-12 18:40 +0200
[tip:ras/core] x86/mce: Add a wrapper around mce_log() for injection tip-bot for Borislav Petkov <tipbot@zytor.com> - 2015-08-13 13:00 +0200
[PATCH 03/13] x86/mce: Don't use percpu workqueues Borislav Petkov <bp@alien8.de> - 2015-08-12 18:40 +0200
[tip:ras/core] x86/mce: Don't use percpu workqueues "tip-bot for Chen, Gong" <tipbot@zytor.com> - 2015-08-13 12:50 +0200
[PATCH 11/13] x86/mce: Rename rcu_dereference_check_mce() to mce_log_get_idx_check() Borislav Petkov <bp@alien8.de> - 2015-08-12 18:40 +0200
[tip:ras/core] x86/mce: Rename rcu_dereference_check_mce() to mce_log_get_idx_check() tip-bot for Borislav Petkov <tipbot@zytor.com> - 2015-08-13 13:00 +0200
[PATCH 04/13] x86/mce: Remove the MCE ring for Action Optional errors Borislav Petkov <bp@alien8.de> - 2015-08-12 18:40 +0200
[tip:ras/core] x86/mce: Remove the MCE ring for Action Optional errors "tip-bot for Chen, Gong" <tipbot@zytor.com> - 2015-08-13 12:50 +0200
[PATCH 13/13] x86/ras: Move AMD MCE injector to arch/x86/ras/ Borislav Petkov <bp@alien8.de> - 2015-08-12 18:40 +0200
[tip:ras/core] x86/ras: Move AMD MCE injector to arch/x86/ras/ tip-bot for Borislav Petkov <tipbot@zytor.com> - 2015-08-13 13:00 +0200
[PATCH 10/13] RAS: Add a menuconfig option with descriptive text Borislav Petkov <bp@alien8.de> - 2015-08-12 18:40 +0200
[tip:ras/core] RAS: Add a menuconfig option with descriptive text tip-bot for Borislav Petkov <tipbot@zytor.com> - 2015-08-13 13:00 +0200
csiph-web