diff mbox

[v3,08/13] pc: apic_common: reset APIC ID to initial ID when switching into x2APIC mode

Message ID 1476352367-69400-9-git-send-email-imammedo@redhat.com
State New
Headers show

Commit Message

Igor Mammedov Oct. 13, 2016, 9:52 a.m. UTC
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>
---
 hw/intc/apic_common.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Radim Krčmář Oct. 13, 2016, 2:11 p.m. UTC | #1
2016-10-13 11:52+0200, 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 <imammedo@redhat.com>
> ---

Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>

>  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);
>      }
>  }
> -- 
> 2.7.4
> 
>
diff mbox

Patch

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);
     }
 }