]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
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)
committerMarcelo Tosatti <mtosatti@redhat.com>
Wed, 2 Jun 2010 15:58:43 +0000 (12:58 -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 0e561a5070ac1f043704831ff598615377f34eac..1b6a3beb2b0852302e3e7bcf725d142791229190 100644 (file)
@@ -3668,6 +3668,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