]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
x86/apic: fix potential Protection Fault during shutdown
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 15 Jun 2011 19:44:44 +0000 (20:44 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 15 Jun 2011 19:44:44 +0000 (20:44 +0100)
This is a rare case, but if the BIOS is set to uniprocessor, and Xen
is booted with 'lapic x2apic', Xen will switch into x2apic mode, which
will cause a protection fault when disabling the local APIC.  This
leads to a general protection fault as this code is also in the fault
handler.

When x2apic mode is enabled, the only tranlsation which does
not result in a protection fault is to clear both the EN and EXTD
bits, which is safe to do in all cases, even if you are in xapic
mode rather than x2apic mode.

The linux code from which this is derrived is protected by an
if ( ! x2apic_mode ...) clause which is how they get away with it.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@novell.com>
xen-unstable changeset:   23512:0feb98534a87
xen-unstable date:        Tue Jun 14 12:47:45 2011 +0100

xen/arch/x86/apic.c

index 3a0f6fb72519bb0b92b00ce4368836146a141d12..587042c4fbc12a8f6a86b72bbe33a44be2ce86e6 100644 (file)
@@ -351,7 +351,8 @@ void disable_local_APIC(void)
     if (enabled_via_apicbase) {
         uint64_t msr_content;
         rdmsrl(MSR_IA32_APICBASE, msr_content);
-        wrmsrl(MSR_IA32_APICBASE, msr_content & ~MSR_IA32_APICBASE_ENABLE);
+        wrmsrl(MSR_IA32_APICBASE, msr_content &
+               ~(MSR_IA32_APICBASE_ENABLE|MSR_IA32_APICBASE_EXTD));
     }
 }