From: "Jan Beulich" Subject: Re: [PATCH 1 of 7] APIC BUG: fix potential Protection Fault during shutdown Date: Tue, 14 Jun 2011 09:44:39 +0100 Message-ID: <4DF73B970200007800046F4D@nat28.tlf.novell.com> References: <076c3034c8c7f7dea4b3.1307984568@andrewcoop.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <076c3034c8c7f7dea4b3.1307984568@andrewcoop.uk.xensource.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Andrew Cooper Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org >>> On 13.06.11 at 19:02, Andrew Cooper wrote: > 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. >=20 > 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. >=20 > The linux code from which this is derrived is protected by an > if ( ! x2apic_mode ...) clause which is how they get away with it. >=20 > Signed-off-by: Andrew Cooper Acked-by: Jan Beulich You may want to submit a similar patch to Linux (which is what this code got derived from), so that in the future no-one will get surprised that this is different in Xen and Linux. Otoh, interestingly this is being done only for x86-32 in Linux, and I highly doubt any X2APIC capable machine would boot with APIC disabled. Jan > diff -r 37c77bacb52a -r 076c3034c8c7 xen/arch/x86/apic.c > --- a/xen/arch/x86/apic.c Mon May 23 17:38:28 2011 +0100 > +++ b/xen/arch/x86/apic.c Mon Jun 13 17:45:43 2011 +0100 > @@ -340,7 +340,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_ENABL= E); > + wrmsrl(MSR_IA32_APICBASE, msr_content & > + ~(MSR_IA32_APICBASE_ENABLE|MSR_IA32_APICBASE_EXTD)); > } > } > =20 >=20 > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com=20 > http://lists.xensource.com/xen-devel=20