]> xenbits.xensource.com Git - xen.git/commitdiff
x86:x2apic: Disable x2apic on x86-32 permanently
authorKeir Fraser <keir@xen.org>
Fri, 21 Jan 2011 15:58:27 +0000 (15:58 +0000)
committerKeir Fraser <keir@xen.org>
Fri, 21 Jan 2011 15:58:27 +0000 (15:58 +0000)
x2apic initialization on x86_32 uses vcpu pointer before it is
initialized. As x2apic is unlikely to be used on x86_32, this patch
disables x2apic permanently on x86_32. It also asserts the sanity of
vcpu pointer before dereference to prevent further misuse.

Signed-off-by: Fengzhe Zhang <fengzhe.zhang@intel.com>
xen/arch/x86/apic.c

index 1590c3a1712033a9419b965c4a7658d8b0cb5e89..ceefc6784d940339617b1f47f553c92f487140c9 100644 (file)
@@ -961,6 +961,22 @@ void __init x2apic_bsp_setup(void)
     if ( !cpu_has_x2apic )
         return;
 
+#ifdef __i386__
+    clear_bit(X86_FEATURE_X2APIC, boot_cpu_data.x86_capability);
+    if ( x2apic_enabled )
+    {
+        uint64_t msr_content;
+        rdmsrl(MSR_IA32_APICBASE, msr_content);
+        msr_content &= ~(MSR_IA32_APICBASE_ENABLE | MSR_IA32_APICBASE_EXTD);
+        wrmsrl(MSR_IA32_APICBASE, msr_content);
+        msr_content |= MSR_IA32_APICBASE_ENABLE;
+        wrmsrl(MSR_IA32_APICBASE, msr_content);
+        x2apic_enabled = 0;
+    }
+    printk("x2APIC disabled permanently on x86_32.\n");
+    return;
+#endif
+
     if ( !opt_x2apic )
     {
         if ( !x2apic_enabled )