From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn3TG-0001CN-V9 for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:51:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn3TF-00058O-0s for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:51:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55360) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn3TE-000585-Qg for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:51:20 -0400 From: Igor Mammedov Date: Thu, 22 Sep 2016 14:50:50 +0200 Message-Id: <1474548655-157373-10-git-send-email-imammedo@redhat.com> In-Reply-To: <1474548655-157373-1-git-send-email-imammedo@redhat.com> References: <1474548655-157373-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH v2 09/14] 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: qemu-devel@nongnu.org Cc: rkrcmar@redhat.com, ehabkost@redhat.com, mst@redhat.com, kevin@koconnor.net, pbonzini@redhat.com, lersek@redhat.com, chao.gao@intel.com, peterx@redhat.com, liuxiaojian6@huawei.com 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 --- 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 e246cf3..492afb3 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -39,6 +39,11 @@ void cpu_set_apic_base(DeviceState *dev, uint64_t val) if (dev) { APICCommonState *s = APIC_COMMON(dev); APICCommonClass *info = 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 = s->initial_apic_id; + } info->set_base(s, val); } } -- 2.7.4