mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [Patch V1 1/2] x86, mce: Remove unused declarations
@ 2015-06-29 23:38 Ashok Raj
  2015-06-29 23:38 ` [Patch V1 2/2] x86, mce: clear Local MCE opt-in before kexec Ashok Raj
  2015-06-30 17:55 ` [Patch V1 1/2] x86, mce: Remove unused declarations Borislav Petkov
  0 siblings, 2 replies; 4+ messages in thread
From: Ashok Raj @ 2015-06-29 23:38 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ashok Raj, linux-edac, Boris Petkov, Tony Luck

Remove unused references

Signed-off-by: Ashok Raj <ashok.raj@intel.com>
---
 arch/x86/include/asm/mce.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index 8ba4d7a..b7a3a34 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -174,16 +174,12 @@ void cmci_clear(void);
 void cmci_reenable(void);
 void cmci_rediscover(void);
 void cmci_recheck(void);
-void lmce_clear(void);
-void lmce_enable(void);
 #else
 static inline void mce_intel_feature_init(struct cpuinfo_x86 *c) { }
 static inline void cmci_clear(void) {}
 static inline void cmci_reenable(void) {}
 static inline void cmci_rediscover(void) {}
 static inline void cmci_recheck(void) {}
-static inline void lmce_clear(void) {}
-static inline void lmce_enable(void) {}
 #endif
 
 #ifdef CONFIG_X86_MCE_AMD
-- 
2.4.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Patch V1 2/2] x86, mce: clear Local MCE opt-in before kexec.
  2015-06-29 23:38 [Patch V1 1/2] x86, mce: Remove unused declarations Ashok Raj
@ 2015-06-29 23:38 ` Ashok Raj
  2015-06-30 18:39   ` Borislav Petkov
  2015-06-30 17:55 ` [Patch V1 1/2] x86, mce: Remove unused declarations Borislav Petkov
  1 sibling, 1 reply; 4+ messages in thread
From: Ashok Raj @ 2015-06-29 23:38 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ashok Raj, linux-edac, Boris Petkov, Tony Luck

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>
---
 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 b7a3a34..efa0bce 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -140,10 +140,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
 
@@ -170,12 +172,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 8a72a33..7836fe6 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1669,6 +1669,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;
@@ -1732,6 +1743,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 844f56c..1cd0d9c 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_intel.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_intel.c
@@ -435,7 +435,7 @@ static void intel_init_cmci(void)
 	cmci_recheck();
 }
 
-void intel_init_lmce(void)
+static void intel_init_lmce(void)
 {
 	u64 val;
 
@@ -448,9 +448,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 6e338e3..1149083 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -30,6 +30,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,
@@ -363,6 +364,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 be8e1bd..892ffd2 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:
@@ -244,6 +245,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);
 }
 
-- 
2.4.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch V1 1/2] x86, mce: Remove unused declarations
  2015-06-29 23:38 [Patch V1 1/2] x86, mce: Remove unused declarations Ashok Raj
  2015-06-29 23:38 ` [Patch V1 2/2] x86, mce: clear Local MCE opt-in before kexec Ashok Raj
@ 2015-06-30 17:55 ` Borislav Petkov
  1 sibling, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2015-06-30 17:55 UTC (permalink / raw)
  To: Ashok Raj; +Cc: linux-kernel, linux-edac, Boris Petkov, Tony Luck

On Mon, Jun 29, 2015 at 07:38:14PM -0400, Ashok Raj wrote:
> Remove unused references
> 
> Signed-off-by: Ashok Raj <ashok.raj@intel.com>
> ---
>  arch/x86/include/asm/mce.h | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
> index 8ba4d7a..b7a3a34 100644
> --- a/arch/x86/include/asm/mce.h
> +++ b/arch/x86/include/asm/mce.h
> @@ -174,16 +174,12 @@ void cmci_clear(void);
>  void cmci_reenable(void);
>  void cmci_rediscover(void);
>  void cmci_recheck(void);
> -void lmce_clear(void);
> -void lmce_enable(void);
>  #else
>  static inline void mce_intel_feature_init(struct cpuinfo_x86 *c) { }
>  static inline void cmci_clear(void) {}
>  static inline void cmci_reenable(void) {}
>  static inline void cmci_rediscover(void) {}
>  static inline void cmci_recheck(void) {}
> -static inline void lmce_clear(void) {}
> -static inline void lmce_enable(void) {}
>  #endif
>  
>  #ifdef CONFIG_X86_MCE_AMD

Applied, thanks.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch V1 2/2] x86, mce: clear Local MCE opt-in before kexec.
  2015-06-29 23:38 ` [Patch V1 2/2] x86, mce: clear Local MCE opt-in before kexec Ashok Raj
@ 2015-06-30 18:39   ` Borislav Petkov
  0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2015-06-30 18:39 UTC (permalink / raw)
  To: Ashok Raj; +Cc: linux-kernel, linux-edac, Boris Petkov, Tony Luck

On Mon, Jun 29, 2015 at 07:38:15PM -0400, Ashok Raj wrote:
> 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>
> ---
>  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(-)

No complaints, looks ok to me. Applied, thanks.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-06-30 18:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-29 23:38 [Patch V1 1/2] x86, mce: Remove unused declarations Ashok Raj
2015-06-29 23:38 ` [Patch V1 2/2] x86, mce: clear Local MCE opt-in before kexec Ashok Raj
2015-06-30 18:39   ` Borislav Petkov
2015-06-30 17:55 ` [Patch V1 1/2] x86, mce: Remove unused declarations Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome