From patchwork Thu Oct 13 09:52:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 681724 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3svmbQ4qF4z9s5g for ; Thu, 13 Oct 2016 21:06:26 +1100 (AEDT) Received: from localhost ([::1]:39049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bucu7-0008PP-Ht for incoming@patchwork.ozlabs.org; Thu, 13 Oct 2016 06:06:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buchM-0005ir-W3 for qemu-devel@nongnu.org; Thu, 13 Oct 2016 05:53:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1buchK-0004mt-Ul for qemu-devel@nongnu.org; Thu, 13 Oct 2016 05:53:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buchK-0004mh-Oi for qemu-devel@nongnu.org; Thu, 13 Oct 2016 05:53:10 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 276E2C04B921; Thu, 13 Oct 2016 09:53:10 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9D9qmC8025723; Thu, 13 Oct 2016 05:53:08 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 13 Oct 2016 11:52:42 +0200 Message-Id: <1476352367-69400-9-git-send-email-imammedo@redhat.com> In-Reply-To: <1476352367-69400-1-git-send-email-imammedo@redhat.com> References: <1476352367-69400-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 13 Oct 2016 09:53:10 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 08/13] pc: apic_common: reset APIC ID to initial ID when switching into x2APIC mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, liuxiaojian6@huawei.com, mst@redhat.com, rkrcmar@redhat.com, peterx@redhat.com, kevin@koconnor.net, kraxel@redhat.com, pbonzini@redhat.com, lersek@redhat.com, chao.gao@intel.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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čmář --- 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 = 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); } }