RAS: Merge mce_amd_inj into mce-inject
Borislav Petkov
maintainerPATCH 1/4 x86/mce: Merge mce_amd_inj into mce-inject
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Reuse mce_amd_inj's debugfs interface so that mce-inject can benefit from it too. The old functionality is still preserved under CONFIG_X86_MCELOG_LEGACY.
--- arch/x86/Kconfig | 2 +- arch/x86/Makefile | 2 - arch/x86/include/asm/processor.h | 5 + arch/x86/kernel/cpu/mcheck/mce-inject.c | 540 +++++++++++++++++++++++++++++++- arch/x86/ras/Kconfig | 11 - arch/x86/ras/Makefile | 2 - arch/x86/ras/mce_amd_inj.c | 492 ----------------------------- 7 files changed, 531 insertions(+), 523 deletions(-) delete mode 100644 arch/x86/ras/Makefile delete mode 100644 arch/x86/ras/mce_amd_inj.c
arch/x86/Kconfig +1 -1
@@ -1082,7 +1082,7 @@ config X86_MCE_THRESHOLD def_bool y config X86_MCE_INJECT - depends on X86_MCE && X86_LOCAL_APIC && X86_MCELOG_LEGACY + depends on X86_MCE && X86_LOCAL_APIC && DEBUG_FS tristate "Machine check injector support" ---help--- Provide support for injecting machine checks for testing purposes.
arch/x86/Makefile +0 -2
@@ -257,8 +257,6 @@ drivers-$(CONFIG_PM) += arch/x86/power/ drivers-$(CONFIG_FB) += arch/x86/video/ -drivers-$(CONFIG_RAS) += arch/x86/ras/ - #### # boot loader support. Several targets are kept for legacy purposes
arch/x86/include/asm/processor.h +5 -0
@@ -901,8 +901,13 @@ static inline int mpx_disable_management(void) }#endif /* CONFIG_X86_INTEL_MPX */ +#ifdef CONFIG_CPU_SUP_AMD extern u16 amd_get_nb_id (int cpu);extern u32 amd_get_nodes_per_socket (void ); +#else +static inline u16 amd_get_nb_id (int cpu) {return 0 ; } +static inline u32 amd_get_nodes_per_socket (void ) {return 0 ; } +#endif static inline uint32_t hypervisor_cpuid_base (const char *sig,uint32_t leaves) {
arch/x86/kernel/cpu/mcheck/mce-inject.c +525 -15
582 lines not on this page · raw message
arch/x86/ras/Kconfig +0 -11
@@ -1,13 +1,3 @@ -config MCE_AMD_INJ - tristate "Simple MCE injection interface for AMD processors" - depends on RAS && X86_MCE && DEBUG_FS && AMD_NB - default n - help - This is a simple debugfs interface to inject MCEs and test different - aspects of the MCE handling code. - - WARNING: Do not even assume this interface is staying stable! - config RAS_CEC bool "Correctable Errors Collector" depends on X86_MCE && MEMORY_FAILURE && DEBUG_FS
@@ -20,4 +10,3 @@ config RAS_CEC Bear in mind that this is absolutely useless if your platform doesn't have ECC DIMMs and doesn't have DRAM ECC checking enabled in the BIOS. -
arch/x86/ras/Makefile deleted +0 -2
@@ -1,2 +0,0 @@ -obj-$(CONFIG_MCE_AMD_INJ) += mce_amd_inj.o -
arch/x86/ras/mce_amd_inj.c deleted +0 -492
492 lines not on this page · raw message
Borislav Petkov
maintainerPATCH 2/4 x86/mce: Get rid of register_mce_write_callback()
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Make the mcelog call a notifier which lands in the injector module and does the injection. This allows for mce-inject to be a normal kernel module now.
--- arch/x86/include/asm/mce.h | 4 -- arch/x86/kernel/cpu/mcheck/dev-mcelog.c | 47 +++++++++++++++++----- arch/x86/kernel/cpu/mcheck/mce-inject.c | 66 +++++++++---------------------- arch/x86/kernel/cpu/mcheck/mce-internal.h | 6 ++- 4 files changed, 61 insertions(+), 62 deletions(-)
arch/x86/include/asm/mce.h +0 -4
@@ -285,10 +285,6 @@ int mce_notify_irq(void); DECLARE_PER_CPU(struct mce, injectm); -extern void register_mce_write_callback (ssize_t (*)(struct file *filp, -const char __user *ubuf, -size_t usize,loff_t *off)); -/* Disable CMCI/polling for MCA bank claimed by firmware */ extern void mce_disable_bank (int bank);
arch/x86/kernel/cpu/mcheck/dev-mcelog.c +37 -10
67 lines not on this page · raw message
arch/x86/kernel/cpu/mcheck/mce-inject.c +19 -47
105 lines not on this page · raw message
arch/x86/kernel/cpu/mcheck/mce-internal.h +5 -1
@@ -100,7 +100,11 @@ static inline bool mce_cmp(struct mce *m1, struct mce *m2)extern struct device_attribute dev_attr_trigger;#ifdef CONFIG_X86_MCELOG_LEGACY -extern void mce_work_trigger (void ); +void mce_work_trigger (void ); +void mce_register_injector_chain (struct notifier_block *nb); +void mce_unregister_injector_chain (struct notifier_block *nb);#else static inline void mce_work_trigger (void ) { } +static inline void mce_register_injector_chain (struct notifier_block *nb) { } +static inline void mce_unregister_injector_chain (struct notifier_block *nb) { }#endif
Borislav Petkov
maintainerPATCH 3/4 x86/mce: Cleanup include files
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Not really needed.
--- arch/x86/kernel/cpu/mcheck/mce-inject.c | 10 ---------- 1 file changed, 10 deletions(-)
arch/x86/kernel/cpu/mcheck/mce-inject.c +0 -10
@@ -25,20 +25,10 @@#include <linux/cpu.h> #include <linux/debugfs.h> -#include <linux/device.h> -#include <linux/fs.h> -#include <linux/gfp.h> -#include <linux/kdebug.h> #include <linux/kernel.h> -#include <linux/kobject.h> #include <linux/module.h> #include <linux/notifier.h> #include <linux/pci.h> -#include <linux/preempt.h> -#include <linux/sched.h> -#include <linux/smp.h> -#include <linux/string.h> -#include <linux/timer.h> #include <linux/uaccess.h> #include <asm/amd_nb.h>
Borislav Petkov
maintainerPATCH 4/4 x86/mce/mce-inject: Preset the MCE injection struct
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Populate the MCE injection struct before doing initial injection so that values which don't change have sane defaults.
--- arch/x86/kernel/cpu/mcheck/mce-inject.c | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/x86/kernel/cpu/mcheck/mce-inject.c +9 -0
@@ -103,6 +103,13 @@ DEFINE_SIMPLE_ATTRIBUTE(misc_fops, inj_misc_get, inj_misc_set, "%llx\n");DEFINE_SIMPLE_ATTRIBUTE (addr_fops, inj_addr_get, inj_addr_set,"%llx\n" );DEFINE_SIMPLE_ATTRIBUTE (synd_fops, inj_synd_get, inj_synd_set,"%llx\n" ); +static void setup_inj_struct (struct mce *m) +{ +memset (m,0 ,sizeof (struct mce )); + + m->cpuvendor = boot_cpu_data.x86_vendor; +} +/* Update fake mce registers on current CPU. */ static void inject_mce (struct mce *m) {
@@ -700,6 +707,8 @@ static int inject_init(void)register_nmi_handler (NMI_LOCAL , mce_raise_notify,0 ,"mce_notify" );mce_register_injector_chain (&inject_nb); +setup_inj_struct (&i_mce); +pr_info ("Machine check injector initialized\n" );return 0 ;
Borislav Petkov
maintainercover RAS: Merge mce_amd_inj into mce-inject
From: Borislav Petkov <[email protected]>
Hi,
so there's no need to have two different injectors. Also, the mce_amd_inj interface is much more user-friendly because you can simply write full u64 registers directly.
So merge that functionality into mce-inject. The old /dev/mcelog functionality is still there, behind X86_MCELOG_LEGACY.
Also, the second patch removes register_mce_write_callback() and adds an MCE injector notifier which allows us to have mce-inject be a module and thus be able to modprobe it and remove it on a production system in case we want to do some injecting there.
Later, we might reuse that injector notifier for other stuff if it is deemed interesting.
Borislav Petkov (4):
x86/mce: Merge mce_amd_inj into mce-inject x86/mce: Get rid of register_mce_write_callback() x86/mce: Cleanup include files x86/mce/mce-inject: Preset the MCE injection struct
arch/x86/Kconfig | 2 +- arch/x86/Makefile | 2 - arch/x86/include/asm/mce.h | 4 - arch/x86/include/asm/processor.h | 5 + arch/x86/kernel/cpu/mcheck/dev-mcelog.c | 47 ++- arch/x86/kernel/cpu/mcheck/mce-inject.c | 567 +++++++++++++++++++++++++++--- arch/x86/kernel/cpu/mcheck/mce-internal.h | 6 +- arch/x86/ras/Kconfig | 11 - arch/x86/ras/Makefile | 2 - arch/x86/ras/mce_amd_inj.c | 492 -------------------------- 10 files changed, 572 insertions(+), 566 deletions(-) delete mode 100644 arch/x86/ras/Makefile delete mode 100644 arch/x86/ras/mce_amd_inj.c
Signature · 1 line
2.13.0
Quoted 20 lines
-----Original Message-----
From: Borislav Petkov [mailto:[email protected]]
Sent: Tuesday, June 06, 2017 5:33 AM
To: Tony Luck <[email protected]>; Ghannam, Yazen <[email protected]>
Cc: linux-edac <[email protected]>; LKML <linux- [email protected]>
Subject: [PATCH 0/4] RAS: Mergemce_amd_injinto mce-injectFrom: Borislav Petkov <[email protected]>
Hi,
so there's no need to have two different injectors. Also, the
mce_amd_injinterface is much more user-friendly because you can simply write full u64 registers directly.So merge that functionality into mce-inject. The old
/dev/mcelogfunctionality is still there, behindX86_MCELOG_LEGACY.
Quoted 8 lines
Also, the second patch removes
register_mce_write_callback()and adds an MCE injector notifier which allows us to have mce-inject be a module and thus be able to modprobe it and remove it on a production system in case we want to do some injecting there.Later, we might reuse that injector notifier for other stuff if it is deemed interesting.
Built module and tested the mce_amd_inj interface with no problems.
Thanks,
Yazen
Borislav Petkov
maintainerQuoted 3 lines · Yazen
Built module and tested the
mce_amd_injinterface with no problems.Acked-by Yazen Ghannam <[email protected]>
I'll make that -and-tested-by: too.
Thanks.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.