qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [RFC 04/15] i386: create apic_id_for_cpu() function (v2)


From: Eduardo Habkost
Subject: [Qemu-devel] [RFC 04/15] i386: create apic_id_for_cpu() function (v2)
Date: Tue, 7 Aug 2012 16:56:42 -0300

Currently we need a way to calculate the Initial APIC ID using only the
CPU index (without needing a CPU object), as the NUMA fw_cfg data is
APIC-ID-based, and may include data for hotplug CPUs (that don't exist
yet), up to max_cpus.

Changes v1 -> v2:
  - make function return value 'unsigned int' (it's not specific for the 8-bit
    xAPIC ID)
  - move implementation to cpu.c

Signed-off-by: Eduardo Habkost <address@hidden>
---
 target-i386/cpu.c | 14 +++++++++++++-
 target-i386/cpu.h | 10 ++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 857b94e..1703373 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -24,6 +24,10 @@
 #include "cpu.h"
 #include "kvm.h"
 
+#ifndef CONFIG_USER_ONLY
+#include "sysemu.h"
+#endif
+
 #include "qemu-option.h"
 #include "qemu-config.h"
 
@@ -488,6 +492,14 @@ static x86_def_t builtin_x86_defs[] = {
     },
 };
 
+unsigned int apic_id_for_cpu(int cpu_index)
+{
+    /* right now APIC ID == CPU index. this will eventually change to use
+     * the CPU topology configuration properly
+     */
+    return cpu_index;
+}
+
 static int cpu_x86_fill_model_id(char *str)
 {
     uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
@@ -1774,7 +1786,7 @@ static void x86_cpu_initfn(Object *obj)
                         x86_cpuid_get_tsc_freq,
                         x86_cpuid_set_tsc_freq, NULL, NULL, NULL);
 
-    env->cpuid_apic_id = env->cpu_index;
+    env->cpuid_apic_id = apic_id_for_cpu(env->cpu_index);
 }
 
 static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 2a61c81..39ea005 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -910,6 +910,16 @@ void cpu_clear_apic_feature(CPUX86State *env);
 void host_cpuid(uint32_t function, uint32_t count,
                 uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx);
 
+
+/* Calculates initial APIC ID for a specific CPU index
+ *
+ * Currently we need to be able to calculate the APIC ID from the CPU index
+ * alone, as the QEMU<->Seabios interfaces have no concept of "CPU index",
+ * and the NUMA tables need the APIC ID of all CPUs up to max_cpus.
+ */
+unsigned int apic_id_for_cpu(int cpu_index);
+
+
 /* helper.c */
 int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,
                              int is_write, int mmu_idx);
-- 
1.7.11.2




reply via email to

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