[PATCH 0/2] KVM: selftests: Verify sregs and events in sync_regs_test
From: Hemanth Selam
Date: Wed Sep 02 2026 - 08:11:55 EST
sync_regs_test has never actually checked the sregs and events halves of
the kvm_run sync region. compare_sregs() and compare_vcpu_events() have
had empty bodies since the test was written, so the checks run after
every KVM_RUN only ever compared the general purpose registers, and the
events half was never written to at all, hence the standing TODO in
set_and_verify_various().
Patch 1 fills in both comparison helpers. Patch 2 exercises the events
half by masking NMIs through the sync region and verifying KVM applies
it.
To confirm the new checks catch something rather than merely passing,
the same faults were injected before and after the series on an AMD
host:
fault injected before after
sregs.cr4 mismatch ignored caught
sregs.cs.dpl mismatch ignored caught
events.interrupt.shadow mismatch ignored caught
KVM_SYNC_X86_EVENTS left clean n/a caught
Every corruption goes unnoticed before the series and is reported after
it, e.g.
x86/sync_regs_test.c:128: left->cr4 == right->cr4
Register cr4 values did not match: 0x41221, 0x41220
Unmodified, the test passes 20/20 consecutive runs with the series
applied, each patch builds and passes on its own, and the remaining x86
selftests are unchanged either way (61 passed, 24 skipped, with
set_sregs_test failing identically before and after for unrelated
reasons).
Hemanth Selam (2):
KVM: selftests: Actually compare sregs and events in sync_regs_test
KVM: selftests: Verify the events half of the sync regs region
.../selftests/kvm/x86/sync_regs_test.c | 100 +++++++++++++++++-
1 file changed, 98 insertions(+), 2 deletions(-)
--
2.43.7