x86/ras material for 4.3 queue
Subsystems (6)
Luck, Tony
maintainerSome of these almost made it into 4.2, then we found a bug and delayed to fix it. Bug fixes have now been merged back into the original patch series.
The following changes since commit d770e558e21961ad6cfdf0ff7df0eb5d7d4f0754:
Linux 4.2-rc1 (2015-07-05 11:01:52 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras.git tags/please-pull-ras-for-4.3
for you to fetch changes up to 60e23e3342d0ff1201e8ce160a3624bd2ce5ff79:
x86/mce: Clear Local MCE opt-in before kexec (2015-07-06 14:21:12 -0700)
----------------------------------------------------------------
1) Chen Gong series to make mce logging safer in #MC context
2) Boris deleted drain_mcelog_buffer() - don't want/need it now
3) Ashok fixed a local machine check corner case with kexec
----------------------------------------------------------------
Ashok Raj (2):
x86/mce: Remove unused function declarations x86/mce: Clear Local MCE opt-in before kexec
Borislav Petkov (1):
x86/mce: Kill drain_mcelog_buffer()
Chen, Gong (4):
x86/mce: Provide a lockless memory pool to save error records x86/mce: Don't use percpu workqueues
x86/mce: Remove the MCE ring for Action Optional errors x86/mce: Avoid potential deadlock due to printk() in MCE context
arch/x86/Kconfig | 1 + arch/x86/include/asm/mce.h | 8 +- arch/x86/include/uapi/asm/mce.h | 3 +- arch/x86/kernel/cpu/mcheck/Makefile | 2 +- arch/x86/kernel/cpu/mcheck/mce-apei.c | 1 - arch/x86/kernel/cpu/mcheck/mce-genpool.c | 99 +++++++++++++ arch/x86/kernel/cpu/mcheck/mce-internal.h | 12 ++ arch/x86/kernel/cpu/mcheck/mce.c | 221 ++++++++++++++---------------- arch/x86/kernel/cpu/mcheck/mce_intel.c | 20 ++- arch/x86/kernel/process.c | 2 + arch/x86/kernel/smp.c | 2 + 11 files changed, 242 insertions(+), 129 deletions(-) create mode 100644 arch/x86/kernel/cpu/mcheck/mce-genpool.c
Quoted 26 lines · Luck, Tony
Some of these almost made it into 4.2, then we found a bug and delayed to fix it. Bug fixes have now been merged back into the original patch series.
The following changes since commit
d770e558e21961ad6cfdf0ff7df0eb5d7d4f0754:Linux 4.2-rc1 (2015-07-05 11:01:52 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras.gittags/please-pull-ras-for-4.3for you to fetch changes up to
60e23e3342d0ff1201e8ce160a3624bd2ce5ff79:x86/mce: Clear Local MCE opt-in before kexec (2015-07-06 14:21:12 -0700)
----------------------------------------------------------------
1) Chen Gong series to make mce logging safer in #MC context
2) Boris deleteddrain_mcelog_buffer()- don't want/need it now
3) Ashok fixed a local machine check corner case with kexec----------------------------------------------------------------
Ashok Raj (2):
x86/mce: Remove unused function declarations x86/mce: Clear Local MCE opt-in before kexec
Quoted 8 lines
Borislav Petkov (1):
x86/mce: Killdrain_mcelog_buffer()Chen, Gong (4):
x86/mce: Provide a lockless memory pool to save error records x86/mce: Don't use percpu workqueues
x86/mce: Remove the MCE ring for Action Optional errors x86/mce: Avoid potential deadlock due toprintk()in MCE context
So the SOB chains are messed up in a number of commits:
commit ff7d8f3c477ea2340675179cb8393be5566e4617
Author: Chen, Gong <[email protected]>
Date: Wed May 20 15:35:35 2015 -0400
did you rebase a tree from Boris?
Also, please send all patches as part of the submission so that I can comment on individual patches as well.
Thanks,
Ingo
Quoted 1 line · Ingo Molnar
did you rebase a tree from Boris?
Yep, he did. We decided to do so because the fixes missed 4.2 and for 4.3 a clean rebase is just fine.
Quoted 2 lines
Also, please send all patches as part of the submission so that I can comment on individual patches as well.
Sure, lemme do that now as a reply to this message, because now Tony's on vacation. The advantage of being two maintainers.
:-)
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--PATCH 1/7 x86/mce: Provide a lockless memory pool to save error records
From: "Chen, Gong" <[email protected]>
printk() is not safe to use in MCE context. Add a lockless memory allocator pool to save error records in MCE context. Those records will be issued later, in a printk-safe context. The idea is inspired by the APEI/GHES driver.
We're very conservative and allocate only two pages for it but since we're going to use those pages throughout the system's lifetime, we allocate them statically to avoid early boot time allocation woes.
--- arch/x86/Kconfig | 1 + arch/x86/include/uapi/asm/mce.h | 3 +- arch/x86/kernel/cpu/mcheck/Makefile | 2 +- arch/x86/kernel/cpu/mcheck/mce-genpool.c | 99 +++++++++++++++++++++++++++++++ arch/x86/kernel/cpu/mcheck/mce-internal.h | 12 ++++ arch/x86/kernel/cpu/mcheck/mce.c | 8 ++- 6 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 arch/x86/kernel/cpu/mcheck/mce-genpool.c
arch/x86/Kconfig +1 -0
@@ -949,6 +949,7 @@ config X86_REROUTE_FOR_BROKEN_BOOT_IRQS config X86_MCE bool "Machine Check / overheating reporting" + select GENERIC_ALLOCATOR default y ---help--- Machine Check support allows the processor to notify the
arch/x86/include/uapi/asm/mce.h +2 -1
@@ -15,7 +15,8 @@ struct mce {__u64 time;/* wall time_t when error was detected */ __u8 cpuvendor;/* cpu vendor as encoded in system.h */ __u8 inject_flags;/* software inject flags */ -__u16 pad; +__u8 severity; +__u8 usable_addr;__u32 cpuid;/* CPUID 1 EAX */ __u8 cs;/* code segment */ __u8 bank;/* machine check bank */
arch/x86/kernel/cpu/mcheck/Makefile +1 -1
@@ -1,4 +1,4 @@ -obj-y = mce.o mce-severity.o +obj-y = mce.o mce-severity.o mce-genpool.o obj-$(CONFIG_X86_ANCIENT_MCE) += winchip.o p5.o obj-$(CONFIG_X86_MCE_INTEL) += mce_intel.o
arch/x86/kernel/cpu/mcheck/mce-genpool.c new file +99 -0
99 lines not on this page · raw message
arch/x86/kernel/cpu/mcheck/mce-internal.h +12 -0
@@ -13,6 +13,8 @@ enum severity_level { MCE_PANIC_SEVERITY, }; +extern struct atomic_notifier_head x86_mce_decoder_chain; +#define ATTR_LEN 16#define INITIAL_CHECK_INTERVAL 5 * 60/* 5 minutes */
@@ -24,6 +26,16 @@ struct mce_bank {char attrname[ATTR_LEN ];/* attribute name */ }; +struct mce_evt_llist { +struct llist_node llnode; +struct mce mce; +}; + +void mce_genpool_process (void ); +bool mce_genpool_empty (void ); +bool mce_genpool_add (struct mce *mce); +int mce_genpool_init (void ); +extern int (*mce_severity)(struct mce *a,int tolerant,char **msg,bool is_excp);struct dentry *mce_get_debugfs_dir (void );
arch/x86/kernel/cpu/mcheck/mce.c +7 -1
@@ -118,7 +118,7 @@ static void (*quirk_no_way_out)(int bank, struct mce *m, struct pt_regs *regs);* CPU/chipset specific EDAC code can register a notifier call here to print * MCE errors in a human-readable form. */ -static ATOMIC_NOTIFIER_HEAD (x86_mce_decoder_chain); +ATOMIC_NOTIFIER_HEAD (x86_mce_decoder_chain);/* Do initial initialization of a struct mce */ void mce_setup (struct mce *m)
@@ -1731,6 +1731,12 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)return ; } +if (mce_genpool_init ()) { + mca_cfg.disabled = true; +pr_emerg ("Couldn't allocate MCE records pool!\n" ); +return ; + } + machine_check_vector = do_machine_check;__mcheck_cpu_init_generic ();
Signature · 1 line
1.9.0.258.g00eda23
PATCH 2/7 x86/mce: Don't use percpu workqueues
From: "Chen, Gong" <[email protected]>
An MCE is a rare event. Therefore, there's no need to have per-CPU instances of both normal and IRQ workqueues. Make them both global.
[Tony: Folded in subsequent patch from Rui/Boris/Tony for early boot logging]
--- arch/x86/kernel/cpu/mcheck/mce.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/mcheck/mce.c +7 -7
@@ -110,7 +110,8 @@ DEFINE_PER_CPU(mce_banks_t, mce_poll_banks) = {*/ mce_banks_t mce_banks_ce_disabled; -static DEFINE_PER_CPU(struct work_struct, mce_work); +static struct work_struct mce_work; +static struct irq_work mce_irq_work;static void (*quirk_no_way_out)(int bank,struct mce *m,struct pt_regs *regs);
@@ -526,11 +527,9 @@ int mce_available(struct cpuinfo_x86 *c)static void mce_schedule_work (void ) {if (!mce_ring_empty ()) -schedule_work (this_cpu_ptr (&mce_work)); +schedule_work (&mce_work); } -static DEFINE_PER_CPU(struct irq_work, mce_irq_work); -static void mce_irq_work_cb (struct irq_work *entry) {mce_notify_irq ();
@@ -551,7 +550,7 @@ static void mce_report_event(struct pt_regs *regs)return ; } -irq_work_queue (this_cpu_ptr (&mce_irq_work)); +irq_work_queue (&mce_irq_work); }/*
@@ -1742,8 +1741,6 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)__mcheck_cpu_init_generic ();__mcheck_cpu_init_vendor (c);__mcheck_cpu_init_timer (); -INIT_WORK (this_cpu_ptr (&mce_work), mce_process_work); -init_irq_work (this_cpu_ptr (&mce_irq_work), &mce_irq_work_cb); }/*
@@ -2064,6 +2061,9 @@ int __init mcheck_init(void)mcheck_intel_therm_init ();mcheck_vendor_init_severity (); +INIT_WORK (&mce_work, mce_process_work); +init_irq_work (&mce_irq_work, mce_irq_work_cb); +return 0 ; }
Signature · 1 line
1.9.0.258.g00eda23
PATCH 3/7 x86/mce: Remove the MCE ring for Action Optional errors
In reply to Borislav PetkovFrom: "Chen, Gong" <[email protected]>
Use unified genpool to save Action Optional error events and put Action Optional error handling in the same notification chain as MCE error decoding.
[Tony: Folded in subsequent patch from Boris for early boot logging]
--- arch/x86/include/asm/mce.h | 2 +- arch/x86/kernel/cpu/mcheck/mce.c | 135 +++++++++++++++++---------------------- drivers/acpi/acpi_extlog.c | 2 +- drivers/edac/i7core_edac.c | 2 +- drivers/edac/mce_amd.c | 2 +- drivers/edac/sb_edac.c | 2 +- 6 files changed, 65 insertions(+), 80 deletions(-)
arch/x86/include/asm/mce.h +1 -1
@@ -140,7 +140,7 @@ struct mce_vendor_flags {extern struct mce_vendor_flags mce_flags;extern struct mca_config mca_cfg; -extern void mce_register_decode_chain (struct notifier_block *nb); +extern void mce_register_decode_chain (struct notifier_block *nb,bool drain);extern void mce_unregister_decode_chain (struct notifier_block *nb);#include <linux/percpu.h>
arch/x86/kernel/cpu/mcheck/mce.c +60 -75
199 lines not on this page · raw message
drivers/acpi/acpi_extlog.c +1 -1
@@ -286,7 +286,7 @@ static int __init extlog_init(void)*/ old_edac_report_status =get_edac_report_status ();set_edac_report_status (EDAC_REPORTING_DISABLED ); -mce_register_decode_chain (&extlog_mce_dec); +mce_register_decode_chain (&extlog_mce_dec, true);/* enable OS to be involved to take over management from BIOS */ ((struct extlog_l1_head *)extlog_l1_addr)->flags |=FLAG_OS_OPTIN ;
drivers/edac/i7core_edac.c +1 -1
@@ -2424,7 +2424,7 @@ static int __init i7core_init(void) pci_rc =pci_register_driver (&i7core_driver);if (pci_rc >=0 ) { -mce_register_decode_chain (&i7_mce_dec); +mce_register_decode_chain (&i7_mce_dec, true);return 0 ; }
drivers/edac/mce_amd.c +1 -1
@@ -895,7 +895,7 @@ static int __init mce_amd_init(void)pr_info ("MCE: In-kernel MCE decoding enabled.\n" ); -mce_register_decode_chain (&amd_mce_dec_nb); +mce_register_decode_chain (&amd_mce_dec_nb, true);return 0 ; }
drivers/edac/sb_edac.c +1 -1
@@ -2591,7 +2591,7 @@ static int __init sbridge_init(void) pci_rc =pci_register_driver (&sbridge_driver);if (pci_rc >=0 ) { -mce_register_decode_chain (&sbridge_mce_dec); +mce_register_decode_chain (&sbridge_mce_dec, true);if (get_edac_report_status () ==EDAC_REPORTING_DISABLED )sbridge_printk (KERN_WARNING ,"Loading driver, error reporting disabled.\n" );return 0 ;
Signature · 1 line
1.9.0.258.g00eda23
PATCH 4/7 x86/mce: Avoid potential deadlock due to printk() in MCE context
In reply to Borislav PetkovFrom: "Chen, Gong" <[email protected]>
Printing in MCE context is a no-no, currently, as printk is not NMI-safe. If some of the notifiers on the MCE chain call do so, we may deadlock. In order to avoid that, delay printk() to process context where it is safe to do so.
[Tony: Folded in subsequent patch from Boris for early boot logging]
--- arch/x86/kernel/cpu/mcheck/mce-apei.c | 1 - arch/x86/kernel/cpu/mcheck/mce.c | 4 ++-- arch/x86/kernel/cpu/mcheck/mce_intel.c | 1 - 3 files changed, 2 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/mcheck/mce-apei.c +0 -1
@@ -57,7 +57,6 @@ void apei_mce_report_mem_error(int severity, struct cper_sec_mem_err *mem_err) m.addr = mem_err->physical_addr;mce_log (&m); -mce_notify_irq (); }EXPORT_SYMBOL_GPL (apei_mce_report_mem_error);
arch/x86/kernel/cpu/mcheck/mce.c +2 -2
@@ -159,7 +159,8 @@ void mce_log(struct mce *mce)/* Emit the trace record: */ trace_mce_record (mce); -atomic_notifier_call_chain (&x86_mce_decoder_chain,0 , mce); +if (mce_genpool_add (mce)) +irq_work_queue (&mce_irq_work); mce->finished =0 ;wmb ();
@@ -1122,7 +1123,6 @@ void do_machine_check(struct pt_regs *regs, long error_code)/* assuming valid severity level != 0 */ m.severity = severity; m.usable_addr =mce_usable_address (&m); -mce_genpool_add (&m);mce_log (&m);
arch/x86/kernel/cpu/mcheck/mce_intel.c +0 -1
@@ -246,7 +246,6 @@ static void intel_threshold_interrupt(void)return ;machine_check_poll (MCP_TIMESTAMP ,this_cpu_ptr (&mce_banks_owned)); -mce_notify_irq (); }/*
Signature · 1 line
1.9.0.258.g00eda23
PATCH 5/7 x86/mce: Kill drain_mcelog_buffer()
In reply to Borislav PetkovThis used to flush out MCEs logged during early boot and which were in the MCA registers from a previous system run. No need for that now, since we're moving to a genpool.
--- arch/x86/include/asm/mce.h | 2 +- arch/x86/kernel/cpu/mcheck/mce.c | 44 ++-------------------------------------- drivers/acpi/acpi_extlog.c | 2 +- drivers/edac/i7core_edac.c | 2 +- drivers/edac/mce_amd.c | 2 +- drivers/edac/sb_edac.c | 2 +- 6 files changed, 7 insertions(+), 47 deletions(-)
arch/x86/include/asm/mce.h +1 -1
@@ -140,7 +140,7 @@ struct mce_vendor_flags {extern struct mce_vendor_flags mce_flags;extern struct mca_config mca_cfg; -extern void mce_register_decode_chain (struct notifier_block *nb,bool drain); +extern void mce_register_decode_chain (struct notifier_block *nb);extern void mce_unregister_decode_chain (struct notifier_block *nb);#include <linux/percpu.h>
arch/x86/kernel/cpu/mcheck/mce.c +2 -42
64 lines not on this page · raw message
drivers/acpi/acpi_extlog.c +1 -1
@@ -286,7 +286,7 @@ static int __init extlog_init(void)*/ old_edac_report_status =get_edac_report_status ();set_edac_report_status (EDAC_REPORTING_DISABLED ); -mce_register_decode_chain (&extlog_mce_dec, true); +mce_register_decode_chain (&extlog_mce_dec);/* enable OS to be involved to take over management from BIOS */ ((struct extlog_l1_head *)extlog_l1_addr)->flags |=FLAG_OS_OPTIN ;
drivers/edac/i7core_edac.c +1 -1
@@ -2424,7 +2424,7 @@ static int __init i7core_init(void) pci_rc =pci_register_driver (&i7core_driver);if (pci_rc >=0 ) { -mce_register_decode_chain (&i7_mce_dec, true); +mce_register_decode_chain (&i7_mce_dec);return 0 ; }
drivers/edac/mce_amd.c +1 -1
@@ -895,7 +895,7 @@ static int __init mce_amd_init(void)pr_info ("MCE: In-kernel MCE decoding enabled.\n" ); -mce_register_decode_chain (&amd_mce_dec_nb, true); +mce_register_decode_chain (&amd_mce_dec_nb);return 0 ; }
drivers/edac/sb_edac.c +1 -1
@@ -2591,7 +2591,7 @@ static int __init sbridge_init(void) pci_rc =pci_register_driver (&sbridge_driver);if (pci_rc >=0 ) { -mce_register_decode_chain (&sbridge_mce_dec, true); +mce_register_decode_chain (&sbridge_mce_dec);if (get_edac_report_status () ==EDAC_REPORTING_DISABLED )sbridge_printk (KERN_WARNING ,"Loading driver, error reporting disabled.\n" );return 0 ;
Signature · 1 line
1.9.0.258.g00eda23
PATCH 6/7 x86/mce: Remove unused function declarations
In reply to Borislav PetkovFrom: Ashok Raj <[email protected]>
Remove unused function declarations.
--- arch/x86/include/asm/mce.h | 4 ---- 1 file changed, 4 deletions(-)
arch/x86/include/asm/mce.h +0 -4
@@ -185,16 +185,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
Signature · 1 line
1.9.0.258.g00eda23
PATCH 7/7 x86/mce: Clear Local MCE opt-in before kexec
In reply to Borislav PetkovFrom: Ashok Raj <[email protected]>
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.
--- 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(-)
arch/x86/include/asm/mce.h +4 -0
@@ -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 ) {}
arch/x86/kernel/cpu/mcheck/mce.c +30 -0
@@ -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. */
arch/x86/kernel/cpu/mcheck/mce_intel.c +18 -1
@@ -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 (); +}
arch/x86/kernel/process.c +2 -0
@@ -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 ();
arch/x86/kernel/smp.c +2 -0
@@ -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); }
Signature · 1 line
1.9.0.258.g00eda23
Re: [PATCH 7/7] x86/mce: Clear Local MCE opt-in before kexec
Quoted 5 lines · Borislav Petkov
From: Ashok Raj <[email protected]>
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.
What happens if an offline-but-not-unplugged CPU gets an MCE? Or does this code also clear CR4.MCE?
--Andy
Re: [PATCH 7/7] x86/mce: Clear Local MCE opt-in before kexec
Quoted 8 lines · Andy Lutomirski
Quoted 5 lines
From: Ashok Raj <[email protected]>
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.
What happens if an offline-but-not-unplugged CPU gets an MCE? Or does this code also clear CR4.MCE?
kexec doesn't use cpu_offline() path, but uses an IPI to all threads before letting the BSP jump to new kernel.
In this patch, we only turned off the LMCE opt-in. CR4.MCE isn't touched.
if an offline-but-not-unplugged CPU gets an MCE its usually fatal and will be broadcast to all cpus in the system.
Turning off CR4.MCE would not be good, since any thread that receives an MCE and has CR4.MCE=0 would result in resetting the whole system.
There are other bugs in MCE in the offline path that i'm working on to send a patch update.
for e.g. one such bug is that during CPU_DOWN_PREPARE mce_disable_cpu() turns off MCx_CTL().
Machine check banks in uncore are visible to all logical cpus. We should not clear them. Today offlining a single cpu would disable MCE generation for any of the uncore banks. I have them brewing in a test, should release in a couple weeks or so.
We can only clear banks if they are only thread local during cpu_offline(). We don't have such banks today (but coming). Most banks are either core scoped or socket scoped.
Cheers,
Ashok
Re: [PATCH 1/7] x86/mce: Provide a lockless memory pool to save error records
In reply to Borislav PetkovQuoted 7 lines · Borislav Petkov
From: "Chen, Gong" <[email protected]>
arch/x86/include/uapi/asm/mce.h +0
-0
arch/x86/include/uapi/asm/mce.h struct mce { · line 22
Quoted 9 lines
arch/x86/include/uapi/asm/mce.h +2
-1@@ -15,7 +15,8 @@ struct mce {__u64 time;/* wall time_t when error was detected */ __u8 cpuvendor;/* cpu vendor as encoded in system.h */ __u8 inject_flags;/* software inject flags */ -__u16 pad; +__u8 severity; +__u8 usable_addr;__u32 cpuid;/* CPUID 1 EAX */ __u8 cs;/* code segment */ __u8 bank;/* machine check bank */
So this change appears to be completely unrelated to the stated purpose of this patch?
Quoted 6 lines
+/*
+ *printk()is not safe in MCE context. This is a lock-less memory allocator
+ * used to save error information organized in a lock-less list.
+ *
+ * This memory pool is only to be used to save MCE records in MCE context.
+ * MCE events are rare so a fixed size memory pool should be enough. Use
Missing comma.
Quoted 12 lines
+ * 2 pages to save MCE events for now (~80 MCE records at most).
+ */arch/x86/include/uapi/asm/mce.h +9
-0+#define MCE_POOLSZ (2 * PAGE_SIZE) +bool mce_genpool_add (struct mce *mce) +{ +struct mce_evt_llist *node; + +if (!mce_evt_pool) +return false; + + node = (void *)gen_pool_alloc (mce_evt_pool,sizeof (*node));
arch/x86/include/uapi/asm/mce.h
Quoted 10 lines
arch/x86/include/uapi/asm/mce.h +10
-0+if (!node) { +pr_warn_ratelimited ("MCE records pool full!\n" ); +return false; + } + +memcpy (&node->mce, mce,sizeof (*mce)); +llist_add (&node->llnode, &mce_event_llist); + +return true; +}
So I think the standard pattern for allocation failures with integer types is to return -ENOMEM, not bool. This really matters, because:
Quoted 4 lines
arch/x86/include/uapi/asm/mce.h +4
-0+ +static int mce_genpool_create (void ) +{ +struct gen_pool *tmpp;
arch/x86/include/uapi/asm/mce.h
Quoted 10 lines
arch/x86/include/uapi/asm/mce.h +10
-0+int ret = -ENOMEM ; + + tmpp =gen_pool_create (ilog2 (sizeof (struct mce_evt_llist )),-1 ); +if (!tmpp) + goto out; + + ret =gen_pool_add (tmpp, (unsigned long )genpool_buf,MCE_POOLSZ ,-1 ); +if (ret) { +gen_pool_destroy (tmpp); + goto out;
here gen_pool_add() has an inverted logic, and they looks confusing.
Furthermore, why do we spell it 'mce_genpool' if the generic facility is spelling it gen_pool?
Also, I'm questioning the whole premise of the patches:
Quoted 6 lines
+/*
+ *printk()is not safe in MCE context. This is a lock-less memory allocator
+ * used to save error information organized in a lock-less list.
+ *
+ * This memory pool is only to be used to save MCE records in MCE context.
+ * MCE events are rare so a fixed size memory pool should be enough. Use
So how are we going to report uncorrectable errors that forcibly crash/panic the system if we cannot use printk? How will the admin learn what was amiss?
Thanks,
Ingo
Re: [PATCH 1/7] x86/mce: Provide a lockless memory pool to save error records
Quoted 2 lines · Ingo Molnar
So this change appears to be completely unrelated to the stated purpose of this patch?
I'll carve it out into a separate patch.
Quoted 1 line
Missing comma.
Good point.
Quoted 2 lines
So I think the standard pattern for allocation failures with integer types is to return
-ENOMEM, not bool. This really matters, because:
...
Quoted 1 line
here
gen_pool_add()has an inverted logic, and they looks confusing.
Lemme fix that.
Quoted 2 lines
Furthermore, why do we spell it '
mce_genpool' if the generic facility is spelling itgen_pool?
mce_gen_pool() it is.
Quoted 3 lines
So how are we going to report uncorrectable errors that forcibly crash/panic the system if we cannot use printk? How will the admin learn what was amiss?
There's no change to that policy - we still panic for MCEs of MCE_PANIC_SEVERITY and higher. And mce_panic() does use printk() to dump that critical information.
The gen_pool stuff is for MCEs for which the hw still raises an #MC exception but the severity code determines that we don't need to panic but do recovery action.
However, we don't want to call printk() from the #MC exception handler since it is NMI-like atomic context and printk is not NMI-safe (yet). Those printks are issued later, in process context when we're done with the exception handler and recovery action.
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--Re: [PATCH 1/7] x86/mce: Provide a lockless memory pool to save error records
Quoted 5 lines · Borislav Petkov
Quoted 2 lines
So how are we going to report uncorrectable errors that forcibly crash/panic the system if we cannot use printk? How will the admin learn what was amiss?
There's no change to that policy - we still panic for MCEs of
MCE_PANIC_SEVERITYand higher. Andmce_panic()does useprintk()to dump that critical information.
Ok, I see: through mce_print().
Quoted 8 lines
The
gen_poolstuff is for MCEs for which the hw still raises an #MC exception but the severity code determines that we don't need to panic but do recovery action.However, we don't want to call
printk()from the #MC exception handler since it is NMI-like atomic context and printk is not NMI-safe (yet). Those printks are issued later, in process context when we're done with the exception handler and recovery action.
Ok - no objections then.
Thanks,
Ingo