Overview of patches: * 1-3 are just header dependency/conflict cleanups * 4 is the APIC ID initialization patch sent earlier by Igor * 5-6 change the KVM code to use the APIC ID as vcpu_id, on i386 * 7-21 refactor the PC initialization code to allow a compatibility argument to be easily set by the pc-1.2 machine-init function later * 22-23 just make the PC code ready to support APIC IDs != cpu_index (but keeps existing behavior) * 24 just changes testing infrastructure to allow a target-i386-specific unit-test to be added * 25 adds utility functions that implement the topology-based APIC ID calculation * 26 just makes pc-1.2 and pc-1.3 use different machine-init functions * 27 finally implements the fix, keeping compatibility on pc-1.2
Changes v2 -> v3: * Not creating a new "PC" class, anymore * Patch 1: move qemu_open() & qemu_close() to qemu-stdio.h, too * Include "[PATCH v5] target-i386: initialize APIC at CPU level" from Igor * Let the PC code set the APIC ID directly, between cpu_x86_init() and x86_cpu_realize() calls, instead of adding new arguments to X86CPU init functions * Changes to the PC initialization code: introduce a PCInitArgs struct * Use a separate machine init function, that enables the compatibility mode on pc-1.2 Changes v1 -> v2: * Created a qemu-stdio.h file for some I/O related definitions * Now all the topology-based APIC ID calculation logic is inside pc.c * I have now created a "PC" object just to carry the machine-type compatibility flag that keeps the previous behavior. * Dropped the qemu_global_get() function, as it is not needed anymore * Fixed compile errors on non-x86 targets with KVM enabled (ppc, s390x) * Add more descriptive comments on THE FW_CFG_MAX_CPUS calculation * Add pointers to documentation on topology.h Bug description: The CPU APIC IDs generated by QEMU are broken if the number of cores-per-socket or threads-per-core are not powers of 2, as the bits on the APIC ID do not correspond to what's expected to reflect the CPU sockets/cores/threads topology[1]. [1] http://software.intel.com/en-us/articles/intel-64-architecture-processor-topolog y-enumeration/ This series is available on git, at: https://github.com/ehabkost/qemu-hacks/commits/apicid-topology-v3 Eduardo Habkost (26): move I/O-related definitions from qemu-common.h to a new header (qemu-stdio.h) cpus.h: include qemu-stdio.h hw/apic.c: rename bit functions to not conflict with bitops.h kvm: create kvm_arch_vcpu_id() function target-i386: kvm: set vcpu_id to APIC ID instead of CPU index pc: pc_init1(): always use rom_memory on pc_memory_init() call pc: pc_init1(): remove MemoryRegion arguments pc: pc_init1(): get QEMUMachineInitArgs argument pc: create PCInitArgs struct pc: add PC_DEFAULT_CPU_MODEL #define pc: add PCInitArgs parameter to pc_cpus_init() pc: pass PCInitArgs struct to pc_memory_init() pc: use FWCfgState* instead of void* for fw_cfg data pc: rename bochs_bios_init() to pc_bios_init() pc: pass PCInitArgs struct to pc_bios_init() xen_machine_pv: use cpu_init() instead of cpu_x86_init() pc: isolate the code that create CPUs cpu_x86_init: check for x86_cpu_realize() errors target-i386: do not call x86_cpu_realize() on cpu_x86_init() fw_cfg: remove FW_CFG_MAX_CPUS from fw_cfg_init() pc: set CPU APIC ID explicitly pc: set fw_cfg data based on APIC ID calculation tests: support target-specific unit tests target-i386: topology & APIC ID utility functions pc: create separate init function for pc-1.3 pc: generate APIC IDs according to CPU topology Igor Mammedov (1): target-i386: initialize APIC at CPU level cpus.h | 2 + hw/apic.c | 35 +++++----- hw/fw_cfg.c | 1 - hw/pc.c | 185 ++++++++++++++++++++++++++++--------------------- hw/pc.h | 32 ++++++--- hw/pc_piix.c | 140 +++++++++++++++++-------------------- hw/ppc_newworld.c | 1 + hw/ppc_oldworld.c | 1 + hw/sun4m.c | 3 + hw/sun4u.c | 1 + hw/xen_machine_pv.c | 4 +- kvm-all.c | 2 +- kvm.h | 3 + qemu-common.h | 59 +--------------- qemu-stdio.h | 76 ++++++++++++++++++++ target-i386/cpu.c | 57 +++++++++++++++ target-i386/cpu.h | 14 ++++ target-i386/helper.c | 7 +- target-i386/kvm.c | 5 ++ target-i386/topology.h | 133 +++++++++++++++++++++++++++++++++++ target-ppc/kvm.c | 5 ++ target-s390x/kvm.c | 5 ++ tests/.gitignore | 1 + tests/Makefile | 19 ++++- tests/test-x86-cpuid.c | 101 +++++++++++++++++++++++++++ 25 files changed, 645 insertions(+), 247 deletions(-) create mode 100644 qemu-stdio.h create mode 100644 target-i386/topology.h create mode 100644 tests/test-x86-cpuid.c -- 1.7.11.7