[Top][All Lists]
[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
- [Qemu-devel] [RFC 00/15] attempt to fix CPU topology info on CPU APIC IDs, Eduardo Habkost, 2012/08/07
- [Qemu-devel] [RFC 05/15] remove FW_CFG_MAX_CPUS from fw_cfg_init(), Eduardo Habkost, 2012/08/07
- [Qemu-devel] [RFC 03/15] kvm: set vcpu_id to APIC ID instead of CPU index, Eduardo Habkost, 2012/08/07
- [Qemu-devel] [RFC 09/15] isolate qdev-independent parts of qdev_prop_set_globals(), Eduardo Habkost, 2012/08/07
- [Qemu-devel] [RFC 10/15] create object_prop_set_globals(), Eduardo Habkost, 2012/08/07
- [Qemu-devel] [RFC 11/15] rename qdev_prop_register_global_list to qemu_globals_register_list, Eduardo Habkost, 2012/08/07
- [Qemu-devel] [RFC 12/15] create qemu_global_get() function, Eduardo Habkost, 2012/08/07
- [Qemu-devel] [RFC 08/15] move global properties code to global-properties.c, Eduardo Habkost, 2012/08/07
- [Qemu-devel] [RFC 04/15] i386: create apic_id_for_cpu() function (v2),
Eduardo Habkost <=
- [Qemu-devel] [RFC 06/15] pc: set FW_CFG data based on APIC ID calculation, Eduardo Habkost, 2012/08/07
- [Qemu-devel] [RFC 01/15] cpus.h: include cpu-common.h, Eduardo Habkost, 2012/08/07
- [Qemu-devel] [RFC 13/15] tests: support target-specific unit tests, Eduardo Habkost, 2012/08/07
- [Qemu-devel] [RFC 07/15] qdev: allow qdev_prop_parse() to report errors, Eduardo Habkost, 2012/08/07
- [Qemu-devel] [RFC 02/15] hw/apic.c: rename bit functions to not conflict with bitops.h (v2), Eduardo Habkost, 2012/08/07
- [Qemu-devel] [RFC 14/15] i386: topology & APIC ID utility functions (v2), Eduardo Habkost, 2012/08/07