[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 22/27] pc: set CPU APIC ID explicitly
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PATCH 22/27] pc: set CPU APIC ID explicitly |
Date: |
Wed, 24 Oct 2012 15:49:56 -0200 |
The PC code takes care of CPU topology, and CPU topology affect the CPU
APIC ID. So the PC CPU initialization code needs to set the APIC ID
explicitly.
By now, keep the existing behavior but create a apic_id_for_cpu()
function that will be changed later to implement appropriate
topology-dependent behavior.
The cpuid_apic_id field is used only at:
- x86_cpu_apic_init(), called from x86_cpu_realize()
- kvm_init_vcpu(), that is called from the VCPU thread
created by qemu_init_vcpu(), called by x86_cpu_realize()
- helper_cpuid(), called only when the VCPU is already running
- kvm_arch_init_vcpu(), that's called by kvm_init_vcpu()
So it's safe to change it before x86_cpu_realize() is called.
Signed-off-by: Eduardo Habkost <address@hidden>
---
This is based on the patch that I have originally suybmitted as:
Subject: pc: create apic_id_for_cpu() function (v3)
---
hw/pc.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/hw/pc.c b/hw/pc.c
index 0e9a00f..eb68851 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -553,6 +553,21 @@ static void bochs_bios_write(void *opaque, uint32_t addr,
uint32_t val)
}
}
+/* 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.
+ */
+static uint32_t apic_id_for_cpu(PCInitArgs *args, int cpu_index)
+{
+ /* right now APIC ID == CPU index. this will eventually change to use
+ * the CPU topology configuration properly
+ */
+ return cpu_index;
+}
+
int e820_add_entry(uint64_t address, uint64_t length, uint32_t type)
{
int index = le32_to_cpu(e820_table.count);
@@ -870,6 +885,13 @@ static void pc_cpu_init(PCInitArgs *args, int cpu_index)
exit(1);
}
+ /* Override the default APIC set by the X86CPU init function.
+ * We need to do that because:
+ * - The APIC ID depends on the CPU topology;
+ * - The exact APIC ID used may depend on the machine-type init arguments.
+ */
+ cpu->env.cpuid_apic_id = apic_id_for_cpu(args, cpu_index);
+
x86_cpu_realize(OBJECT(cpu), &err);
if (err) {
error_report("pc_cpu_init: %s\n", error_get_pretty(err));
--
1.7.11.7
- [Qemu-devel] [PATCH 01/27] move I/O-related definitions from qemu-common.h to a new header (qemu-stdio.h), (continued)
- [Qemu-devel] [PATCH 01/27] move I/O-related definitions from qemu-common.h to a new header (qemu-stdio.h), Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 20/27] target-i386: do not call x86_cpu_realize() on cpu_x86_init(), Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 23/27] pc: set fw_cfg data based on APIC ID calculation, Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 02/27] cpus.h: include qemu-stdio.h, Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 12/27] pc: add PCInitArgs parameter to pc_cpus_init(), Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 16/27] pc: pass PCInitArgs struct to pc_bios_init(), Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 21/27] fw_cfg: remove FW_CFG_MAX_CPUS from fw_cfg_init(), Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 25/27] target-i386: topology & APIC ID utility functions, Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 27/27] pc: generate APIC IDs according to CPU topology, Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 06/27] target-i386: kvm: set vcpu_id to APIC ID instead of CPU index, Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 22/27] pc: set CPU APIC ID explicitly,
Eduardo Habkost <=
- [Qemu-devel] [PATCH 15/27] pc: rename bochs_bios_init() to pc_bios_init(), Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 08/27] pc: pc_init1(): remove MemoryRegion arguments, Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 18/27] pc: isolate the code that create CPUs, Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 10/27] pc: create PCInitArgs struct, Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 07/27] pc: pc_init1(): always use rom_memory on pc_memory_init() call, Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 17/27] xen_machine_pv: use cpu_init() instead of cpu_x86_init(), Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 13/27] pc: pass PCInitArgs struct to pc_memory_init(), Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 09/27] pc: pc_init1(): get QEMUMachineInitArgs argument, Eduardo Habkost, 2012/10/24
- [Qemu-devel] [PATCH 24/27] tests: support target-specific unit tests, Eduardo Habkost, 2012/10/24