Current topology handling is close to non-existent. As things stand, APIC
IDs are allocated through the apic_id=vcpu_id*2 relation without giving any
hints to the OS on how to parse the x2APIC ID of a given CPU and assuming
the guest will assume 2 threads per core.
This series involves bringing x2APIC IDs into the migration stream, so
older guests keep operating as they used to and enhancing Xen+toolstack so
new guests get topology information consistent with their x2APIC IDs. As a
side effect of this, x2APIC IDs are now packed and don't have (unless under
a pathological case) gaps.
Further work ought to allow combining this topology configurations with
gang-scheduling of guest hyperthreads into affine physical hyperthreads.
For the time being it purposefully keeps the configuration of "1 socket" +
"1 thread per core" + "1 core per vCPU".
Patch 1: Includes x2APIC IDs in the migration stream. This allows Xen to
reconstruct the right x2APIC IDs on migrated-in guests, and
future-proofs itself in the face of x2APIC ID derivation changes.
Patch 2: Minor refactor to expose xc_cpu_policy in libxl
Patch 3: Refactors xen/lib/x86 to work on non-Xen freestanding environments
(e.g: hvmloader)
Patch 4: Remove old assumptions about vcpu_id<->apic_id relationship in hvmloader
Patch 5: Add logic to derive x2APIC IDs given a CPU policy and vCPU IDs
Patch 6: Includes a simple topology generator for toolstack so new guests
have topologically consistent information in CPUID
Alejandro Vallejo (6):
xen/x86: Add initial x2APIC ID to the per-vLAPIC save area
tools/xc: Add xc_cpu_policy to the public xenctrl.h header
xen/x86: Refactor xen/lib/x86 so it can be linked in hvmloader
tools/hvmloader: Use cpu_policy to determine APIC IDs
xen/x86: Derive topologically correct x2APIC IDs from the policy
xen/x86: Add topology generator
tools/firmware/hvmloader/Makefile | 7 ++
tools/firmware/hvmloader/config.h | 5 +-
tools/firmware/hvmloader/hvmloader.c | 6 +
tools/firmware/hvmloader/util.c | 3 +-
tools/include/xenguest.h | 23 +++-
tools/libacpi/build.c | 27 ++++-
tools/libacpi/libacpi.h | 5 +-
tools/libs/guest/xg_cpuid_x86.c | 144 ++++++++++++++---------
tools/libs/guest/xg_private.h | 10 --
tools/libs/light/libxl_x86_acpi.c | 21 +++-
tools/tests/cpu-policy/test-cpu-policy.c | 128 ++++++++++++++++++++
xen/arch/x86/cpu-policy.c | 6 +-
xen/arch/x86/cpuid.c | 20 +---
xen/arch/x86/domain.c | 3 +
xen/arch/x86/hvm/vlapic.c | 27 ++++-
xen/arch/x86/include/asm/hvm/vlapic.h | 2 +
xen/include/public/arch-x86/hvm/save.h | 2 +
xen/include/xen/lib/x86/cpu-policy.h | 16 +++
xen/lib/x86/cpuid.c | 12 +-
xen/lib/x86/policy.c | 74 ++++++++++++
xen/lib/x86/private.h | 8 +-
21 files changed, 442 insertions(+), 107 deletions(-)
--
2.34.1