From: Igor Mammedov Date: Wed, 19 Oct 2016 12:05:37 +0000 (+0200) Subject: pc: apic_common: Reset APIC ID to initial ID when switching into x2APIC mode X-Git-Tag: qemu-xen-4.9.0-rc1~123^2~9 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=facb07cd2a3d19ebe2e15380e906eed7d5f7063c;p=qemu-xen.git pc: apic_common: Reset APIC ID to initial ID when switching into x2APIC mode 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ář Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index ea3c8caef5..d78c885509 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); } }