KVM: VMX: Properly return error to userspace on vmentry failure
authorMohammed Gamal <m.gamal005@gmail.com>
Mon, 31 May 2010 19:40:54 +0000 (22:40 +0300)
committerAvi Kivity <avi@redhat.com>
Sun, 1 Aug 2010 07:39:24 +0000 (10:39 +0300)
The vmexit handler returns KVM_EXIT_UNKNOWN since there is no handler
for vmentry failures. This intercepts vmentry failures and returns
KVM_FAIL_ENTRY to userspace instead.

Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/vmx.c

index e71c731433ee2dee1396d38045059fb9c8e24b37..8c9085d44c373ba272649ccbf9342e67e6317d47 100644 (file)
@@ -3665,6 +3665,13 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu)
        if (enable_ept && is_paging(vcpu))
                vcpu->arch.cr3 = vmcs_readl(GUEST_CR3);
 
+       if (exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY) {
+               vcpu->run->exit_reason = KVM_EXIT_FAIL_ENTRY;
+               vcpu->run->fail_entry.hardware_entry_failure_reason
+                       = exit_reason;
+               return 0;
+       }
+
        if (unlikely(vmx->fail)) {
                vcpu->run->exit_reason = KVM_EXIT_FAIL_ENTRY;
                vcpu->run->fail_entry.hardware_entry_failure_reason