diff options
| author | Yosry Ahmed <yosry@kernel.org> | 2026-02-25 03:59:46 +0300 |
|---|---|---|
| committer | Sean Christopherson <seanjc@google.com> | 2026-03-03 02:58:23 +0300 |
| commit | e5cdd34b5f74c4a0c72fe43092192f347d999e77 (patch) | |
| tree | b0e87ad220d9ed653811f6a2ec76403b0fa98aae /tools | |
| parent | 2303ca26fbb005a45aaf5a547465f978df906cb7 (diff) | |
| download | linux-e5cdd34b5f74c4a0c72fe43092192f347d999e77.tar.xz | |
KVM: selftests: Extend state_test to check next_rip
Similar to vGIF, extend state_test to make sure that next_rip is saved
correctly in nested state. GUEST_SYNC() in L2 causes IO emulation by
KVM, which advances the RIP to the value of next_rip. Hence, if next_rip
is saved correctly, its value should match the saved RIP value.
Signed-off-by: Yosry Ahmed <yosry@kernel.org>
Link: https://patch.msgid.link/20260225005950.3739782-5-yosry@kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/testing/selftests/kvm/x86/state_test.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/x86/state_test.c b/tools/testing/selftests/kvm/x86/state_test.c index 57c7546f3d7c..992a52504a4a 100644 --- a/tools/testing/selftests/kvm/x86/state_test.c +++ b/tools/testing/selftests/kvm/x86/state_test.c @@ -236,6 +236,17 @@ void svm_check_nested_state(int stage, struct kvm_x86_state *state) if (stage == 6) TEST_ASSERT_EQ(!!(vmcb->control.int_ctl & V_GIF_MASK), 0); } + + if (kvm_cpu_has(X86_FEATURE_NRIPS)) { + /* + * GUEST_SYNC() causes IO emulation in KVM, in which case the + * RIP is advanced before exiting to userspace. Hence, the RIP + * in the saved state should be the same as nRIP saved by the + * CPU in the VMCB. + */ + if (stage == 6) + TEST_ASSERT_EQ(vmcb->control.next_rip, state->regs.rip); + } } void check_nested_state(int stage, struct kvm_x86_state *state) |
