From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 1/2] VMX: Properly return error to userspace on vmentry failure Date: Tue, 25 May 2010 14:45:59 +0300 Message-ID: <4BFBB877.5030100@redhat.com> References: <1274652064-8267-1-git-send-email-m.gamal005@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: mtosatti@redhat.com, kvm@vger.kernel.org To: Mohammed Gamal Return-path: Received: from mx1.redhat.com ([209.132.183.28]:65504 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750783Ab0EYLqC (ORCPT ); Tue, 25 May 2010 07:46:02 -0400 In-Reply-To: <1274652064-8267-1-git-send-email-m.gamal005@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: On 05/24/2010 01:01 AM, Mohammed Gamal wrote: > 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 > --- > arch/x86/kvm/vmx.c | 7 +++++++ > 1 files changed, 7 insertions(+), 0 deletions(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 99ae513..4edcffb 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -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& ~VMX_EXIT_REASONS_FAILED_VMENTRY; > + return 0; > + } > + > if (unlikely(vmx->fail)) { > vcpu->run->exit_reason = KVM_EXIT_FAIL_ENTRY; > vcpu->run->fail_entry.hardware_entry_failure_reason > How does the user distinguish between KVM_EXIT_FAIL_ENTRY due to an exit reason with bit 31 set and vmlauch/vmresume failure (vmx->fail set)? We need separate exit codes (with documentation in api.txt). -- error compiling committee.c: too many arguments to function