From: David Matlack Subject: [kvm-unit-tests PATCH 07/32] x86: test exit while vmcs02 is loaded Date: Thu, 20 Apr 2017 17:49:39 -0700 Message-ID: <20170421005004.137260-8-dmatlack@google.com> References: <20170421005004.137260-1-dmatlack@google.com> Cc: Peter Feiner , David Matlack To: kvm@vger.kernel.org Return-path: Received: from mail-io0-f169.google.com ([209.85.223.169]:36240 "EHLO mail-io0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033580AbdDUAuP (ORCPT ); Thu, 20 Apr 2017 20:50:15 -0400 Received: by mail-io0-f169.google.com with SMTP id o22so104066998iod.3 for ; Thu, 20 Apr 2017 17:50:15 -0700 (PDT) In-Reply-To: <20170421005004.137260-1-dmatlack@google.com> Sender: kvm-owner@vger.kernel.org List-ID: From: Peter Feiner 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 Signed-off-by: David Matlack --- x86/vmx_tests.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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} }, }; -- 2.12.2.816.g2cccc81164-goog