KVM: selftests: Add test for race in kvm_recalculate_apic_map()
authorMichal Luczaj <mhal@rbox.co>
Fri, 2 Jun 2023 23:32:50 +0000 (16:32 -0700)
committerSean Christopherson <seanjc@google.com>
Sat, 3 Jun 2023 00:21:06 +0000 (17:21 -0700)
commit47d2804bc99ca873470df17c20737b28225a320d
tree7dd9a1f8b6e62f3a3759a87adb81c2e655466237
parent4364b287982bd05bfafa461c80650c732001974b
KVM: selftests: Add test for race in kvm_recalculate_apic_map()

Keep switching between LAPIC_MODE_X2APIC and LAPIC_MODE_DISABLED during
APIC map construction to hunt for TOCTOU bugs in KVM.  KVM's optimized map
recalc makes multiple passes over the list of vCPUs, and the calculations
ignore vCPU's whose APIC is hardware-disabled, i.e. there's a window where
toggling LAPIC_MODE_DISABLED is quite interesting.

Signed-off-by: Michal Luczaj <mhal@rbox.co>
Co-developed-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20230602233250.1014316-4-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/Makefile
tools/testing/selftests/kvm/x86_64/recalc_apic_map_test.c [new file with mode: 0644]