summary refs log tree commit diff stats
path: root/hw/intc/apic_common.c
diff options
context:
space:
mode:
authorBui Quang Minh <minhquangbui99@gmail.com>2024-01-11 22:43:59 +0700
committerMichael S. Tsirkin <mst@redhat.com>2024-02-14 06:09:32 -0500
commitb5ee0468e9d28c6bd47cce70f90b5032dd10ecc2 (patch)
treec423b901c9b931ba9f44c69524fb5c11dc65b4a0 /hw/intc/apic_common.c
parentb2101358e591c9f0a93739dd3aee72935a79af80 (diff)
downloadfocaccia-qemu-b5ee0468e9d28c6bd47cce70f90b5032dd10ecc2.tar.gz
focaccia-qemu-b5ee0468e9d28c6bd47cce70f90b5032dd10ecc2.zip
apic: add support for x2APIC mode
This commit extends the APIC ID to 32-bit long and remove the 255 max APIC
ID limit in userspace APIC. The array that manages local APICs is now
dynamically allocated based on the max APIC ID of created x86 machine.
Also, new x2APIC IPI destination determination scheme, self IPI and x2APIC
mode register access are supported.

Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Message-Id: <20240111154404.5333-3-minhquangbui99@gmail.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/intc/apic_common.c')
-rw-r--r--hw/intc/apic_common.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
index 6c100b48d6..3c43ac9a1d 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -287,6 +287,10 @@ static void apic_common_realize(DeviceState *dev, Error **errp)
     }
     vmstate_register_with_alias_id(NULL, instance_id, &vmstate_apic_common,
                                    s, -1, 0, NULL);
+
+    /* APIC LDR in x2APIC mode */
+    s->extended_log_dest = ((s->initial_apic_id >> 4) << 16) |
+                            (1 << (s->initial_apic_id & 0xf));
 }
 
 static void apic_common_unrealize(DeviceState *dev)
@@ -427,6 +431,11 @@ static void apic_common_set_id(Object *obj, Visitor *v, const char *name,
         return;
     }
 
+    if (value >= 255 && !cpu_has_x2apic_feature(&s->cpu->env)) {
+        error_setg(errp, "APIC ID %d requires x2APIC feature in CPU", value);
+        return;
+    }
+
     s->initial_apic_id = value;
     s->id = (uint8_t)value;
 }