MCE: some fixes and a little cleanup for mce_intel.c
PATCH 1/1 MCE: some fixes and a little cleanup for mce_intel.c
The attached patch fixes a few possible issues (mostly with synchronization and MCEs happening while recovery is running). It also fixes a problem where the system might not properly panic, because the boot CPU might be spinning with interrupts disabled. Lastly, it takes the first step towards having a common trap handler again (for AMD and Intel) in the future, by using more common interfaces.
- Frank
Do not share synchronization variables between the trap handler and the softirq handler, as this will cause problems. Abstract the synchronization bits into functions. Make the synchronization code aware of a panic, so that spinning with interrupts disabled is avoided.
To avoid problems with MCEs happening while we're doing recovery actions in the softirq handler, implement a deferred list of telemetry structures, using the mctelem interfaces. Thist list will get updated atomically, so any additional MCEs will not cause error telemetry to be missed or not handled.
xen/arch/x86/cpu/mcheck/mce.c +23 -5
@@ -23,6 +23,7 @@#include "mce.h" int mce_disabled =0 ; +int is_mc_panic =0 ;unsigned int nr_mce_banks;EXPORT_SYMBOL_GPL (nr_mce_banks);/* non-fatal.o */
@@ -127,6 +128,7 @@ mctelem_cookie_t mcheck_mca_logout(enumswitch (who) {case MCA_MCE_HANDLER : +case MCA_MCE_SCAN : mcg.mc_flags =MC_FLAG_MCE ; which =MC_URGENT ;break ;
@@ -222,8 +224,9 @@ mctelem_cookie_t mcheck_mca_logout(enum cbret =mc_callback_bank_extended (mci, i, status); } -/* Clear status */ -mca_wrmsrl (MSR_IA32_MC0_STATUS +4 * i,0x0ULL ); +if (who !=MCA_MCE_SCAN ) +/* Clear status */ +mca_wrmsrl (MSR_IA32_MC0_STATUS +4 * i,0x0ULL );wmb (); }
@@ -472,6 +475,21 @@ cmn_handler_done: } } +void mcheck_mca_clearbanks (cpu_banks_t bankmask) +{ +int i; +uint64_t status; + +for (i =0 ; i <32 && i < nr_mce_banks; i++) { +if (!test_bit (i, bankmask)) +continue ; +mca_rdmsrl (MSR_IA32_MC0_STATUS + i *4 , status); +if (!(status & MCi_STATUS_VAL)) +continue ; +mca_wrmsrl (MSR_IA32_MC0_STATUS +4 * i,0x0ULL ); + } +} +static int amd_mcheck_init (struct cpuinfo_x86 *ci) {int rc =0 ;
@@ -1220,9 +1238,8 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) uadd_taint (TAINT_ERROR_INJECT ); -on_selected_cpus (cpumask_of_cpu (target), - x86_mc_mceinject, mc_mceinject,1 ,1 ); - +on_selected_cpus (cpumask_of_cpu (target), x86_mc_mceinject, + mc_mceinject,1 ,1 );break ;default :
@@ -1246,6 +1263,7 @@ void set_poll_bankmask(struct cpuinfo_x8 }void mc_panic (char *s) { + is_mc_panic =1 ;console_start_sync ();printk ("Fatal machine check: %s\n" , s); printk("\n"
xen/arch/x86/cpu/mcheck/mce.h +4 -1
@@ -70,7 +70,8 @@ enum mca_source {MCA_MCE_HANDLER ,MCA_POLLER ,MCA_CMCI_HANDLER , -MCA_RESET +MCA_RESET , +MCA_MCE_SCAN }; enum mca_extinfo {
@@ -92,6 +93,8 @@ DECLARE_PER_CPU(cpu_banks_t, poll_bankmaDECLARE_PER_CPU (cpu_banks_t, poll_bankmask);DECLARE_PER_CPU (cpu_banks_t, no_cmci_banks);extern int cmci_support; +extern int is_mc_panic; +extern void mcheck_mca_clearbanks (cpu_banks_t );extern mctelem_cookie_t mcheck_mca_logout (enum mca_source ,cpu_banks_t ,struct mca_summary *);
xen/arch/x86/cpu/mcheck/mce_intel.c +240 -250
609 lines not on this page · raw message
xen/arch/x86/cpu/mcheck/mctelem.c +87 -27
155 lines not on this page · raw message
xen/arch/x86/cpu/mcheck/mctelem.h +4 -0
@@ -67,5 +67,9 @@ extern mctelem_cookie_t mctelem_consume_extern mctelem_cookie_t mctelem_consume_oldest_begin (mctelem_class_t );extern void mctelem_consume_oldest_end (mctelem_cookie_t );extern void mctelem_ack (mctelem_class_t ,mctelem_cookie_t ); +extern void mctelem_defer (mctelem_cookie_t ); +extern void mctelem_process_deferred (unsigned int , +int (*)(unsigned int ,mctelem_cookie_t )); +int mctelem_has_deferred (unsigned int );#endif
xen/include/asm-x86/domain.h +1 -0
@@ -226,6 +226,7 @@ struct domain_mca_msrsuint64_t mci_ctl[MAX_NR_BANKS ];uint16_t nr_injection;struct list_head impact_header; +spinlock_t lock; };struct arch_domain
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Hi, Frank
This patch is fine for us.
Thanks& Regards,
Criping
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Frank van der Linden
Sent: 2009年4月9日 7:15
To: Xen-Devel (E-mail)
Subject: [Xen-devel] [PATCH] MCE: some fixes and a little cleanup for mce_intel.c
The attached patch fixes a few possible issues (mostly with synchronization and MCEs happening while recovery is running). It also fixes a problem where the system might not properly panic, because the boot CPU might be spinning with interrupts disabled. Lastly, it takes the first step towards having a common trap handler again (for AMD and Intel) in the future, by using more common interfaces.
- Frank
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel