diff mbox

[kvm-unit-tests,07/32] x86: test exit while vmcs02 is loaded

Message ID 20170421005004.137260-8-dmatlack@google.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Matlack April 21, 2017, 12:49 a.m. UTC
From: Peter Feiner <pfeiner@google.com>

Before applying "KVM: nVMX: fix lifetime issues for vmcs0", exiting while
vmcs02 was loaded would trigger a VM_BUG_ON.

Signed-off-by: Peter Feiner <pfeiner@google.com>
Signed-off-by: David Matlack <dmatlack@google.com>
---
 x86/vmx_tests.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox

Patch

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index cd18b133a3a3..35af67744971 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -1884,6 +1884,18 @@  int into_exit_handler()
 	return VMX_TEST_VMEXIT;
 }
 
+static void exit_monitor_from_l2_main(void)
+{
+	printf("Calling exit(0) from l2...\n");
+	exit(0);
+}
+
+static int exit_monitor_from_l2_handler(void)
+{
+	report("The guest should have killed the VMM", false);
+	return VMX_TEST_EXIT;
+}
+
 /* name/init/guest_main/exit_handler/syscall_handler/guest_regs */
 struct vmx_test vmx_tests[] = {
 	{ "null", NULL, basic_guest_main, basic_exit_handler, NULL, {0} },
@@ -1914,5 +1926,7 @@  struct vmx_test vmx_tests[] = {
 		disable_rdtscp_exit_handler, NULL, {0} },
 	{ "int3", int3_init, int3_guest_main, int3_exit_handler, NULL, {0} },
 	{ "into", into_init, into_guest_main, into_exit_handler, NULL, {0} },
+	{ "exit_monitor_from_l2_test", NULL, exit_monitor_from_l2_main,
+		exit_monitor_from_l2_handler, NULL, {0} },
 	{ NULL, NULL, NULL, NULL, NULL, {0} },
 };