From: Hemanth Selam <hemanth.selam@gmail.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Shuah Khan <shuah@kernel.org>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: [PATCH 0/2] KVM: selftests: Verify sregs and events in sync_regs_test
Date: Wed, 2 Sep 2026 17:32:33 +0530 [thread overview]
Message-ID: <20260902120235.18486-1-hemanth.selam@gmail.com> (raw)
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
next reply other threads:[~2026-09-02 12:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 12:02 Hemanth Selam [this message]
2026-09-02 12:02 ` [PATCH 1/2] KVM: selftests: Actually compare sregs and events in sync_regs_test Hemanth Selam
[not found] ` <20260902122209.865E61F00A3E@smtp.kernel.org>
2026-09-03 6:17 ` Hemanth Selam
2026-09-02 12:02 ` [PATCH 2/2] KVM: selftests: Verify the events half of the sync regs region Hemanth Selam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260902120235.18486-1-hemanth.selam@gmail.com \
--to=hemanth.selam@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox