On Thu, Jun 01, 2023, Sean Christopherson wrote: > On Fri, May 26, 2023, Sean Christopherson wrote: > > From: Michal Luczaj <mhal@xxxxxxx> > > > > 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@xxxxxxx> > > Co-developed-by: Sean Christopherson <seanjc@xxxxxxxxxx> > > Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx> > > --- > > tools/testing/selftests/kvm/Makefile | 1 + > > .../kvm/x86_64/recalc_apic_map_race.c | 76 +++++++++++++++++++ > > 2 files changed, 77 insertions(+) > > create mode 100644 tools/testing/selftests/kvm/x86_64/recalc_apic_map_race.c > > Since there's another bug+test related to kvm_recalculate_apic_map()[*], I think > it makes sense to name this recalc_apic_map_test, and then fold the LDR test into > this one. The LDR test is tiny enough that I don't think it's worth a separate > binary, even though I generally prefer to keep the selftests small. Actually, the x2APIC test is a better fit in xapic_state_test. I'll probably still rename this to match (almost) every other selftest name.