aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/testing/selftests/kvm
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2020-04-17 12:35:38 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2020-04-21 09:13:13 -0400
commit1d2c6c9bd4b768bb665eeeb793dd50c2cebcbf0c (patch)
treec2b33e7df64ed6afe7b93169032aed06c02fefb5 /tools/testing/selftests/kvm
parentKVM: SVM: avoid infinite loop on NPF from bad address (diff)
downloadwireguard-linux-1d2c6c9bd4b768bb665eeeb793dd50c2cebcbf0c.tar.xz
wireguard-linux-1d2c6c9bd4b768bb665eeeb793dd50c2cebcbf0c.zip
selftests: kvm/set_memory_region_test: do not check RIP if the guest shuts down
On AMD, the state of the VMCB is undefined after a shutdown VMEXIT. KVM takes a very conservative approach to that and resets the guest altogether when that happens. This causes the set_memory_region_test to fail because the RIP is 0xfff0 (the reset vector). Restrict the RIP test to KVM_EXIT_INTERNAL_ERROR in order to fix this. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests/kvm')
-rw-r--r--tools/testing/selftests/kvm/set_memory_region_test.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/testing/selftests/kvm/set_memory_region_test.c b/tools/testing/selftests/kvm/set_memory_region_test.c
index 260e638826dc..b3ece55a2da6 100644
--- a/tools/testing/selftests/kvm/set_memory_region_test.c
+++ b/tools/testing/selftests/kvm/set_memory_region_test.c
@@ -287,10 +287,15 @@ static void test_delete_memory_region(void)
vcpu_regs_get(vm, VCPU_ID, &regs);
- TEST_ASSERT(regs.rip >= final_rip_start &&
- regs.rip < final_rip_end,
- "Bad rip, expected 0x%lx - 0x%lx, got 0x%llx\n",
- final_rip_start, final_rip_end, regs.rip);
+ /*
+ * On AMD, after KVM_EXIT_SHUTDOWN the VMCB has been reinitialized already,
+ * so the instruction pointer would point to the reset vector.
+ */
+ if (run->exit_reason == KVM_EXIT_INTERNAL_ERROR)
+ TEST_ASSERT(regs.rip >= final_rip_start &&
+ regs.rip < final_rip_end,
+ "Bad rip, expected 0x%lx - 0x%lx, got 0x%llx\n",
+ final_rip_start, final_rip_end, regs.rip);
kvm_vm_free(vm);
}