Skip to content

RFC Fix APIC-ID-based CPU topology

Eduardo Habkost qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 RFC Latest18 patches 25 repliesIn review

Changes in v2 from the cover letter

* 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

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/18pc: create "PC" device classhw/pc.c hw/pc.h+24 -016 replies
2/18pc: create PC object on pc_init1()hw/pc_piix.c+3 -03 replies
3/18pc: add PC object argument to some init functionshw/pc.c hw/pc.h hw/pc_piix.c+12 -101 reply
4/18move I/O-related definitions from qemu-common.h to a new header (qemu-stdio.h)qemu-common.h qemu-stdio.h+75 -550 replies
5/18cpus.h: include qemu-stdio.hcpus.h+2 -03 replies
6/18hw/apic.c: rename bit functions to not conflict with bitops.h (v2)hw/apic.c+18 -170 replies
7/18kvm: create kvm_arch_vcpu_id() functionkvm-all.c kvm.h target-i386/kvm.c +2 more+19 -10 replies
8/18target-i386: kvm: set vcpu_id to APIC ID instead of CPU index (v2)target-i386/kvm.c+1 -10 replies
9/18target-i386: cpu: move cpuid_apic_id initialization to cpu_x86_register()target-i386/cpu.c+2 -20 replies
10/18target-i386: cpu: add apic_id argument to cpu_x86_register()target-i386/cpu.c target-i386/cpu.h target-i386/helper.c+4 -40 replies
11/18target-i386: cpu_x86_init: allow APIC ID to be set by callerhw/pc.c target-i386/cpu.h target-i386/helper.c+16 -51 reply
12/18fw_cfg: remove FW_CFG_MAX_CPUS from fw_cfg_init()hw/fw_cfg.c hw/pc.c hw/ppc_newworld.c +3 more+7 -20 replies
13/18pc: set explicit APIC ID for CPUshw/pc.c+4 -40 replies
14/18pc: create apic_id_for_cpu() function (v3)hw/pc.c+15 -10 replies
15/18pc: set fw_cfg data based on APIC ID calculation (v2)hw/pc.c+34 -70 replies
16/18tests: support target-specific unit teststests/Makefile+13 -30 replies
17/18target-i386: topology & APIC ID utility functions (v2)target-i386/topology.h tests/.gitignore tests/Makefile +1 more+239 -01 reply
18/18pc: generate APIC IDs according to CPU topology (v3)hw/pc.c hw/pc_piix.c+44 -50 replies

Reviews trailers per patch

1 of 18 patches has a Reviewed-by or Acked-by.

PatchBlue Swirl
1/18
2/18
3/18
4/18
5/18
6/18
7/18
8/18
9/18
10/18
11/18
12/18
13/18
14/18
15/18
16/18
17/18A-b
18/18

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [Qemu-devel] [RFC v2 00/18] Fix APIC-ID-based CPU topology

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/

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

This series is based on the cpu-queue branch, from:
https://github.com/ehabkost/qemu/commits/cpu-queue
(more exactly, it was based on commit 8ffa1dbb0f4efa3d465d66bcdfbf545c350fe3ae)
This series is available on git, at:
https://github.com/ehabkost/qemu-hacks/commits/work/apicid-rfc-v2-2012-10-03

Eduardo Habkost (18):
pc: create "PC" device class
pc: create PC object on pc_init1()
pc: add PC object argument to some init functions move I/O-related definitions from qemu-common.h to a new header

    (qemu-stdio.h)
  cpus.h: include cpu-stdio.h
  hw/apic.c: rename bit functions to not conflict with bitops.h (v2)
  kvm: create kvm_arch_vcpu_id() function
  target-i386: kvm: set vcpu_id to APIC ID instead of CPU index (v2)
  target-i386: cpu: move cpuid_apic_id initialization to
    cpu_x86_register()

target-i386: cpu: add apic_id argument to cpu_x86_register()
target-i386: cpu_x86_init: allow APIC ID to be set by caller
fw_cfg: remove FW_CFG_MAX_CPUS from fw_cfg_init()
pc: set explicit APIC ID for CPUs
pc: create apic_id_for_cpu() function (v3)
pc: set fw_cfg data based on APIC ID calculation (v2)
tests: support target-specific unit tests
target-i386: topology & APIC ID utility functions (v2)
pc: generate APIC IDs according to CPU topology (v3)

 cpus.h                 |   2 +
 hw/apic.c              |  35 ++++++-------
 hw/fw_cfg.c            |   1 -
 hw/pc.c                | 125 ++++++++++++++++++++++++++++++++++++++++------
 hw/pc.h                |  11 +++-
 hw/pc_piix.c           |  11 +++-
 hw/ppc_newworld.c      |   1 +
 hw/ppc_oldworld.c      |   1 +
 hw/sun4m.c             |   3 ++
 hw/sun4u.c             |   1 +
 kvm-all.c              |   2 +-
 kvm.h                  |   3 ++
 qemu-common.h          |  57 +--------------------
 qemu-stdio.h           |  73 +++++++++++++++++++++++++++
 target-i386/cpu.c      |   6 +--
 target-i386/cpu.h      |   6 +--
 target-i386/helper.c   |  15 +++++-
 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 | 102 +++++++++++++++++++++++++++++++++++++
 24 files changed, 519 insertions(+), 104 deletions(-)
 create mode 100644 qemu-stdio.h
 create mode 100644 target-i386/topology.h
 create mode 100644 tests/test-x86-cpuid.c
Signature · 1 line
1.7.11.4