Bit# 31 in VM-exit reason is set by hardware in both cases of early VM-entry failures and VM-entry failures due to invalid guest state. Whenever VM-entry fails, the nested VMCS is not in "launched" state any more. Hence, __enter_guest() should not set the "launched" state when a VM-entry fails. Signed-off-by: Krish Sadhukhan <krish.sadhukhan@xxxxxxxxxx> Reviewed-by: Karl Heubaum <karl.heubaum@xxxxxxxxxx> --- x86/vmx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/x86/vmx.c b/x86/vmx.c index 872ba11..183d11b 100644 --- a/x86/vmx.c +++ b/x86/vmx.c @@ -1805,6 +1805,8 @@ static void check_for_guest_termination(void) */ static void __enter_guest(u8 abort_flag, struct vmentry_failure *failure) { + bool vm_entry_failure; + TEST_ASSERT_MSG(v2_guest_main, "Never called test_set_guest_func!"); @@ -1812,15 +1814,14 @@ static void __enter_guest(u8 abort_flag, struct vmentry_failure *failure) "Called enter_guest() after guest returned."); vmx_enter_guest(failure); + vm_entry_failure = vmcs_read(EXI_REASON) & VMX_ENTRY_FAILURE; if ((abort_flag & ABORT_ON_EARLY_VMENTRY_FAIL && failure->early) || - (abort_flag & ABORT_ON_INVALID_GUEST_STATE && - vmcs_read(EXI_REASON) & VMX_ENTRY_FAILURE)) { - + (abort_flag & ABORT_ON_INVALID_GUEST_STATE && vm_entry_failure)) { print_vmentry_failure_info(failure); abort(); } - if (!failure->early) { + if (!vm_entry_failure) { launched = 1; check_for_guest_termination(); } -- 2.20.1