From: "Jan Beulich" Subject: [PATCH] x86/mce: CPU notifiers must not be registered a second time during resume Date: Fri, 18 Mar 2011 15:07:16 +0000 Message-ID: <4D8383340200007800037412@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartE7CB2434.1__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" Cc: Jinsong Liu List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartE7CB2434.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline While c/s 22964:f71212f712fd and 23051:93c864c16ab1 fixed issues with CPU onlining, they introduced a problem with resume: mcheck_init() is also being called on that path, and hence checking whether it's running on CPU 0, which is generally not a really good thing, is particularly inappropriate here. Signed-off-by: Jan Beulich --- a/xen/arch/x86/acpi/power.c +++ b/xen/arch/x86/acpi/power.c @@ -187,7 +187,7 @@ static int enter_state(u32 state) =20 device_power_up(); =20 - mcheck_init(&boot_cpu_data); + mcheck_init(&boot_cpu_data, 0); write_cr4(cr4); =20 printk(XENLOG_INFO "Finishing wakeup from ACPI S%d state.\n", state); --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -431,19 +431,13 @@ void __cpuinit identify_cpu(struct cpuin /* AND the already accumulated flags with these */ for ( i =3D 0 ; i < NCAPINTS ; i++ ) boot_cpu_data.x86_capability[i] &=3D c->x86_capabil= ity[i]; - } - - /* Init Machine Check Exception if available. */ - mcheck_init(c); =20 -#if 0 - if (c =3D=3D &boot_cpu_data) - sysenter_setup(); - enable_sep_cpu(); -#endif + mcheck_init(c, 0); + } else { + mcheck_init(c, 1); =20 - if (c =3D=3D &boot_cpu_data) mtrr_bp_init(); + } } =20 /* cpuid returns the value latched in the HW at reset, not the APIC ID --- a/xen/arch/x86/cpu/mcheck/mce.c +++ b/xen/arch/x86/cpu/mcheck/mce.c @@ -793,7 +793,7 @@ static struct notifier_block cpu_nfb =3D { }; =20 /* This has to be run for each processor */ -void mcheck_init(struct cpuinfo_x86 *c) +void mcheck_init(struct cpuinfo_x86 *c, bool_t bsp) { enum mcheck_type inited =3D mcheck_none; =20 @@ -822,7 +822,7 @@ void mcheck_init(struct cpuinfo_x86 *c) switch (c->x86) { case 6: case 15: - inited =3D intel_mcheck_init(c); + inited =3D intel_mcheck_init(c, bsp); break; } break; @@ -844,7 +844,7 @@ void mcheck_init(struct cpuinfo_x86 *c) /* Turn on MCE now */ set_in_cr4(X86_CR4_MCE); =20 - if ( smp_processor_id() =3D=3D 0 ) + if ( bsp ) { /* Early MCE initialisation for BSP. */ if ( cpu_poll_bankmask_alloc(0) ) --- a/xen/arch/x86/cpu/mcheck/mce.h +++ b/xen/arch/x86/cpu/mcheck/mce.h @@ -42,7 +42,7 @@ enum mcheck_type amd_k7_mcheck_init(stru enum mcheck_type amd_k8_mcheck_init(struct cpuinfo_x86 *c); enum mcheck_type amd_f10_mcheck_init(struct cpuinfo_x86 *c); =20 -enum mcheck_type intel_mcheck_init(struct cpuinfo_x86 *c); +enum mcheck_type intel_mcheck_init(struct cpuinfo_x86 *c, bool_t bsp); =20 void intel_mcheck_timer(struct cpuinfo_x86 *c); void mce_intel_feature_init(struct cpuinfo_x86 *c); --- a/xen/arch/x86/cpu/mcheck/mce_intel.c +++ b/xen/arch/x86/cpu/mcheck/mce_intel.c @@ -1297,9 +1297,9 @@ static struct notifier_block cpu_nfb =3D { }; =20 /* p4/p6 family have similar MCA initialization process */ -enum mcheck_type intel_mcheck_init(struct cpuinfo_x86 *c) +enum mcheck_type intel_mcheck_init(struct cpuinfo_x86 *c, bool_t bsp) { - if ( smp_processor_id() =3D=3D 0 ) + if ( bsp ) { /* Early MCE initialisation for BSP. */ if ( cpu_mcabank_alloc(0) ) --- a/xen/include/asm-x86/processor.h +++ b/xen/include/asm-x86/processor.h @@ -555,7 +555,7 @@ void compat_show_guest_stack(struct vcpu extern void mtrr_ap_init(void); extern void mtrr_bp_init(void); =20 -void mcheck_init(struct cpuinfo_x86 *c); +void mcheck_init(struct cpuinfo_x86 *c, bool_t bsp); =20 #define DECLARE_TRAP_HANDLER(_name) \ asmlinkage void _name(void); \ --=__PartE7CB2434.1__= Content-Type: text/plain; name="x86-mcheck_init-bsp.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-mcheck_init-bsp.patch" While c/s 22964:f71212f712fd and 23051:93c864c16ab1 fixed issues with=0ACPU= onlining, they introduced a problem with resume: mcheck_init() is=0Aalso = being called on that path, and hence checking whether it's running=0Aon = CPU 0, which is generally not a really good thing, is particularly=0Ainappr= opriate here.=0A=0ASigned-off-by: Jan Beulich =0A=0A--= - a/xen/arch/x86/acpi/power.c=0A+++ b/xen/arch/x86/acpi/power.c=0A@@ = -187,7 +187,7 @@ static int enter_state(u32 state)=0A =0A device_power_= up();=0A =0A- mcheck_init(&boot_cpu_data);=0A+ mcheck_init(&boot_cpu_= data, 0);=0A write_cr4(cr4);=0A =0A printk(XENLOG_INFO "Finishing = wakeup from ACPI S%d state.\n", state);=0A--- a/xen/arch/x86/cpu/common.c= =0A+++ b/xen/arch/x86/cpu/common.c=0A@@ -431,19 +431,13 @@ void __cpuinit = identify_cpu(struct cpuin=0A /* AND the already accumulated = flags with these */=0A for ( i =3D 0 ; i < NCAPINTS ; i++ )=0A = boot_cpu_data.x86_capability[i] &=3D c->x86_capability[i];= =0A- }=0A-=0A- /* Init Machine Check Exception if available. = */=0A- mcheck_init(c);=0A =0A-#if 0=0A- if (c =3D=3D &boot_cpu_data= )=0A- sysenter_setup();=0A- enable_sep_cpu();=0A-#endif=0A+ = mcheck_init(c, 0);=0A+ } else {=0A+ mcheck_init(c, 1);=0A =0A- = if (c =3D=3D &boot_cpu_data)=0A mtrr_bp_init();=0A+ = }=0A }=0A =0A /* cpuid returns the value latched in the HW at reset, not = the APIC ID=0A--- a/xen/arch/x86/cpu/mcheck/mce.c=0A+++ b/xen/arch/x86/cpu/= mcheck/mce.c=0A@@ -793,7 +793,7 @@ static struct notifier_block cpu_nfb = =3D {=0A };=0A =0A /* This has to be run for each processor */=0A-void = mcheck_init(struct cpuinfo_x86 *c)=0A+void mcheck_init(struct cpuinfo_x86 = *c, bool_t bsp)=0A {=0A enum mcheck_type inited =3D mcheck_none;=0A = =0A@@ -822,7 +822,7 @@ void mcheck_init(struct cpuinfo_x86 *c)=0A = switch (c->x86) {=0A case 6:=0A case 15:=0A- = inited =3D intel_mcheck_init(c);=0A+ inited =3D intel_mcheck_ini= t(c, bsp);=0A break;=0A }=0A break;=0A@@ = -844,7 +844,7 @@ void mcheck_init(struct cpuinfo_x86 *c)=0A /* Turn on = MCE now */=0A set_in_cr4(X86_CR4_MCE);=0A =0A- if ( smp_processor_id= () =3D=3D 0 )=0A+ if ( bsp )=0A {=0A /* Early MCE initialisa= tion for BSP. */=0A if ( cpu_poll_bankmask_alloc(0) )=0A--- = a/xen/arch/x86/cpu/mcheck/mce.h=0A+++ b/xen/arch/x86/cpu/mcheck/mce.h=0A@@ = -42,7 +42,7 @@ enum mcheck_type amd_k7_mcheck_init(stru=0A enum mcheck_type= amd_k8_mcheck_init(struct cpuinfo_x86 *c);=0A enum mcheck_type amd_f10_mch= eck_init(struct cpuinfo_x86 *c);=0A =0A-enum mcheck_type intel_mcheck_init(= struct cpuinfo_x86 *c);=0A+enum mcheck_type intel_mcheck_init(struct = cpuinfo_x86 *c, bool_t bsp);=0A =0A void intel_mcheck_timer(struct = cpuinfo_x86 *c);=0A void mce_intel_feature_init(struct cpuinfo_x86 = *c);=0A--- a/xen/arch/x86/cpu/mcheck/mce_intel.c=0A+++ b/xen/arch/x86/cpu/m= check/mce_intel.c=0A@@ -1297,9 +1297,9 @@ static struct notifier_block = cpu_nfb =3D {=0A };=0A =0A /* p4/p6 family have similar MCA initialization = process */=0A-enum mcheck_type intel_mcheck_init(struct cpuinfo_x86 = *c)=0A+enum mcheck_type intel_mcheck_init(struct cpuinfo_x86 *c, bool_t = bsp)=0A {=0A- if ( smp_processor_id() =3D=3D 0 )=0A+ if ( bsp )=0A = {=0A /* Early MCE initialisation for BSP. */=0A if ( = cpu_mcabank_alloc(0) )=0A--- a/xen/include/asm-x86/processor.h=0A+++ = b/xen/include/asm-x86/processor.h=0A@@ -555,7 +555,7 @@ void compat_show_gu= est_stack(struct vcpu=0A extern void mtrr_ap_init(void);=0A extern void = mtrr_bp_init(void);=0A =0A-void mcheck_init(struct cpuinfo_x86 *c);=0A+void= mcheck_init(struct cpuinfo_x86 *c, bool_t bsp);=0A =0A #define DECLARE_TRA= P_HANDLER(_name) \=0A asmlinkage void _name(void); = \=0A --=__PartE7CB2434.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__PartE7CB2434.1__=--