Received: from eggs.gnu.org ([2001:4830:134:3::10]:56312) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bygIP-0007pu-J9 for qemu-devel@nongnu.org; Mon, 24 Oct 2016 10:32:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bygIO-0006Od-Mb for qemu-devel@nongnu.org; Mon, 24 Oct 2016 10:32:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50926) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bygIO-0006OM-Gq for qemu-devel@nongnu.org; Mon, 24 Oct 2016 10:32:12 -0400 From: Eduardo Habkost Date: Mon, 24 Oct 2016 12:31:35 -0200 Message-Id: <1477319505-20181-8-git-send-email-ehabkost@redhat.com> In-Reply-To: <1477319505-20181-1-git-send-email-ehabkost@redhat.com> References: <1477319505-20181-1-git-send-email-ehabkost@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 07/17] pc: apic_common: Reset APIC ID to initial ID when switching into x2APIC mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Paolo Bonzini , Richard Henderson , qemu-devel@nongnu.org, Igor Mammedov From: Igor Mammedov SDM: x2APIC State Transitions: State Changes From xAPIC Mode to x2APIC Mode " Any APIC ID value written to the memory-mapped local APIC ID register is not preserved " Signed-off-by: Igor Mammedov Reviewed-by: Radim Kr=C4=8Dm=C3=A1=C5=99 Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- hw/intc/apic_common.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index ea3c8ca..d78c885 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -40,6 +40,11 @@ void cpu_set_apic_base(DeviceState *dev, uint64_t val) if (dev) { APICCommonState *s =3D APIC_COMMON(dev); APICCommonClass *info =3D APIC_COMMON_GET_CLASS(s); + /* switching to x2APIC, reset possibly modified xAPIC ID */ + if (!(s->apicbase & MSR_IA32_APICBASE_EXTD) && + (val & MSR_IA32_APICBASE_EXTD)) { + s->id =3D s->initial_apic_id; + } info->set_base(s, val); } } --=20 2.7.4