[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 07/12] target-i386/cpu: Introduce apic_id_for_cpu() fu
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [RFC 07/12] target-i386/cpu: Introduce apic_id_for_cpu() function |
Date: |
Wed, 9 Jan 2013 16:53:47 -0200 |
This function will be used by both the CPU initialization code and the
fw_cfg table initialization code.
Later this function will be updated to generate APIC IDs according to
the CPU topology.
Signed-off-by: Eduardo Habkost <address@hidden>
---
target-i386/cpu.c | 17 ++++++++++++++++-
target-i386/cpu.h | 2 ++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 492656c..33787dc 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2192,6 +2192,21 @@ void x86_cpu_realize(Object *obj, Error **errp)
cpu_reset(CPU(cpu));
}
+/* 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 (without requiring a CPU object), as the QEMU<->Seabios interfaces
have
+ * no concept of "CPU index", and the NUMA tables on fw_cfg need the APIC ID of
+ * all CPUs up to max_cpus.
+ */
+uint32_t apic_id_for_cpu(unsigned int cpu_index)
+{
+ /* right now APIC ID == CPU index. this will eventually change to use
+ * the CPU topology configuration properly
+ */
+ return cpu_index;
+}
+
static void x86_cpu_initfn(Object *obj)
{
CPUState *cs = CPU(obj);
@@ -2226,7 +2241,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 = cs->cpu_index;
+ env->cpuid_apic_id = apic_id_for_cpu(cs->cpu_index);
/* init various static tables used in TCG mode */
if (tcg_enabled() && !inited) {
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index f3c9df5..dbd9899 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -1238,4 +1238,6 @@ void disable_kvm_pv_eoi(void);
/* Return name of 32-bit register, from a R_* constant */
const char *get_register_name_32(unsigned int reg);
+uint32_t apic_id_for_cpu(unsigned int cpu_index);
+
#endif /* CPU_I386_H */
--
1.7.11.7
- Re: [Qemu-devel] [RFC 01/12] kvm: add KVM_FEATURE_CLOCKSOURCE_STABLE_BIT fake #define, (continued)
- [Qemu-devel] [RFC 05/12] target-i386: kvm: Set vcpu_id to APIC ID instead of CPU index, Eduardo Habkost, 2013/01/09
- [Qemu-devel] [RFC 08/12] cpus.h: Make constant smp_cores/smp_threads available on *-user, Eduardo Habkost, 2013/01/09
- [Qemu-devel] [RFC 03/12] pc: Reverse pc_init_pci() compatibility logic, Eduardo Habkost, 2013/01/09
- [Qemu-devel] [RFC 06/12] fw_cfg: Remove FW_CFG_MAX_CPUS from fw_cfg_init(), Eduardo Habkost, 2013/01/09
- [Qemu-devel] [RFC 09/12] pc: Set fw_cfg data based on APIC ID calculation, Eduardo Habkost, 2013/01/09
- [Qemu-devel] [RFC 12/12] pc: Generate APIC IDs according to CPU topology, Eduardo Habkost, 2013/01/09
- [Qemu-devel] [RFC 04/12] kvm: Create kvm_arch_vcpu_id() function, Eduardo Habkost, 2013/01/09
- [Qemu-devel] [RFC 07/12] target-i386/cpu: Introduce apic_id_for_cpu() function,
Eduardo Habkost <=
- [Qemu-devel] [RFC 10/12] tests: Support target-specific unit tests, Eduardo Habkost, 2013/01/09
- [Qemu-devel] [RFC 02/12] target-i386: Don't set any KVM flag by default if KVM is disabled, Eduardo Habkost, 2013/01/09
- [Qemu-devel] [RFC 11/12] target-i386: Topology & APIC ID utility functions, Eduardo Habkost, 2013/01/09
- Re: [Qemu-devel] [RFC 00/12] target-i386: Fix APIC-ID-based topology (v4), Eduardo Habkost, 2013/01/17