KVM: x86: Fix physical APIC map routing for aliased xAPIC IDs
Status from this message: Applied to kvm-x86 misc, thanks!
Get series with b4
b4 am [email protected]Versions newest first
Patches in v2 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | KVM: x86: Prefer exact vCPU ID matches for physical APIC map aliasesDocumentation/ arch/ | +9 | 0 replies | |
| 2/2 | KVM: selftests: Test exact vCPU ID matching for aliased xAPIC IDstools/ tools/ | +218 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 0/2] KVM: x86: Fix physical APIC map routing for aliased xAPIC IDs
Fix physical APIC map routing when an xAPIC-mode vCPU with an ID above 0xff is created before a vCPU whose ID matches its truncated xAPIC ID.
With KVM_X2APIC_API_USE_32BIT_IDS enabled, the existing alias entry in the xAPIC range can prevent the lower-ID vCPU from being reached via its xAPIC ID, and result in incorrect delivery of INIT/SIPI during CPU hotplug.
Following Sean's proposal [1], always allow the vCPU whose ID exactly matches the aliased xAPIC ID to install an entry in the map, even if one is already present. The full-ID (i.e. x2APIC ID) routes are still used to reach the higher-ID vCPUs in xAPIC mode, preserving KVM hotplug behavior.
The standalone selftest covers both creation orders and checks delivery to both the aliased xAPIC ID ("low") and the full x2APIC ID ("high") destinations. Example output on an unpatched kernel:
ok 1 Destination 0x1d: Lower-ID vCPU 29 created first. # Expected IRQ only on vCPU 29.
# Higher-ID vCPU 285: IRQ vector 0xe0 not delivered. # Lower-ID vCPU 29: IRQ vector 0xe0 delivered.
ok 2 Destination 0x11d: Lower-ID vCPU 29 created first. # Expected IRQ only on vCPU 285.
# Higher-ID vCPU 285: IRQ vector 0xe1 delivered.
# Lower-ID vCPU 29: IRQ vector 0xe1 not delivered. not ok 3 Destination 0x1d: Higher-ID vCPU 285 created first. # Expected IRQ only on vCPU 29.
# Higher-ID vCPU 285: IRQ vector 0xe0 delivered.
# Lower-ID vCPU 29: IRQ vector 0xe0 not delivered. ok 4 Destination 0x11d: Higher-ID vCPU 285 created first. # Expected IRQ only on vCPU 285.
# Higher-ID vCPU 285: IRQ vector 0xe1 delivered.
# Lower-ID vCPU 29: IRQ vector 0xe1 not delivered. # Totals: pass:3 fail:1 xfail:0 xpass:0 skip:0 error:0
Note the third test case fails because vCPU 285 was created before vCPU 29.
Changes since v1 [2]:
- Prefer an exact vCPU ID match instead of selecting the lowest vCPU ID, and update the errata wording.
- Move the selftest out of recalc_apic_map_test into a standalone apic_id_routing_test.
- Cover both creation orders, and check delivery via the higher vCPU's full x2APIC ID.
- Use kselftest, allowing the full-ID test to run even when an earlier alias check fails in unpatched kernels.
Thank you,
Alejandro
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Alejandro Jimenez (2):
KVM: x86: Prefer exact vCPU ID matches for physical APIC map aliases
KVM: selftests: Test exact vCPU ID matching for aliased xAPIC IDs
Documentation/virt/kvm/x86/errata.rst | 9 +- arch/x86/kvm/lapic.c | 7 +- tools/testing/selftests/kvm/Makefile.kvm | 1 + .../selftests/kvm/x86/apic_id_routing_test.c | 217 ++++++++++++++++++ 4 files changed, 227 insertions(+), 7 deletions(-) create mode 100644 tools/testing/selftests/kvm/x86/apic_id_routing_test.c
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
Signature · 1 line
2.47.3