summary refs log tree commit diff stats
path: root/hw/intc/apic_common.c
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2016-10-19 14:05:37 +0200
committerEduardo Habkost <ehabkost@redhat.com>2016-10-24 17:29:15 -0200
commitfacb07cd2a3d19ebe2e15380e906eed7d5f7063c (patch)
treec6ace8206da18cfd5d2d56bbfe38d6cc74edc2ba /hw/intc/apic_common.c
parent4c34897aed0721ed6ea88168aa45579787534e25 (diff)
downloadfocaccia-qemu-facb07cd2a3d19ebe2e15380e906eed7d5f7063c.tar.gz
focaccia-qemu-facb07cd2a3d19ebe2e15380e906eed7d5f7063c.zip
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 <imammedo@redhat.com>
Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'hw/intc/apic_common.c')
-rw-r--r--hw/intc/apic_common.c5
1 files changed, 5 insertions, 0 deletions
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);
     }
 }