qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 07/11] pc: set APIC ID based on socket/core/thread i


From: Igor Mammedov
Subject: [Qemu-devel] [PATCH 07/11] pc: set APIC ID based on socket/core/thread ids if it's not been set yet
Date: Thu, 23 Jun 2016 16:54:25 +0200

CPU added with device_add help won't have APIC ID set,
so set it according to socket/core/thread ids provided
with device_add command.

Signed-off-by: Igor Mammedov <address@hidden>
---
 hw/i386/pc.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 87352ae..63e9bb6 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1758,13 +1758,23 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
                             DeviceState *dev, Error **errp)
 {
     int idx;
+    CPUArchId *cpu_slot;
+    X86CPUTopoInfo topo;
     X86CPU *cpu = X86_CPU(dev);
     PCMachineState *pcms = PC_MACHINE(hotplug_dev);
-    CPUArchId *cpu_slot = pc_find_cpu(pcms, CPU(dev), &idx);
 
+    if (cpu->apic_id == 0xFFFFFFFF) {
+        /* APIC ID not set, set it based on socket/core/thread properties */
+        X86CPUTopoInfo topo = { cpu->socket, cpu->core, cpu->thread };
+        cpu->apic_id = apicid_from_topo_ids(smp_cores, smp_threads, &topo);
+    }
+
+    cpu_slot = pc_find_cpu(pcms, CPU(dev), &idx);
     if (!cpu_slot) {
-        error_setg(errp, "Invalid CPU index with APIC ID (%" PRIu32
-                   "), valid range 0:%d", cpu->apic_id,
+        x86_topo_ids_from_apicid(cpu->apic_id, smp_cores, smp_threads, &topo);
+        error_setg(errp, "Invalid CPU[socket: %d, core: %d, thread: %d] with"
+                  " APIC ID (%" PRIu32 "), valid index range 0:%d",
+                   topo.pkg_id, topo.core_id, topo.smt_id, cpu->apic_id,
                    pcms->possible_cpus->len - 1);
         return;
     }
@@ -1780,8 +1790,6 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
      * added CPUs so that query_hotpluggable_cpus would show correct values
      */
     if (cpu->thread == -1 || cpu->core == -1 || cpu->socket == -1) {
-        X86CPUTopoInfo topo;
-
         x86_topo_ids_from_apicid(cpu->apic_id, smp_cores, smp_threads, &topo);
         cpu->thread = topo.smt_id;
         cpu->core = topo.core_id;
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]