From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH 3/4] KVM: nVMX: Check all exceptions for intercept during delivery to L2 Date: Wed, 25 Sep 2013 17:19:48 +0300 Message-ID: <20130925141948.GC30317@redhat.com> References: <1380102696-25267-1-git-send-email-gleb@redhat.com> <1380102696-25267-4-git-send-email-gleb@redhat.com> <5242EC70.6010003@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: Paolo Bonzini Return-path: Received: from mx1.redhat.com ([209.132.183.28]:11192 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755447Ab3IYOTt (ORCPT ); Wed, 25 Sep 2013 10:19:49 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8PEJn6F006879 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 Sep 2013 10:19:49 -0400 Content-Disposition: inline In-Reply-To: <5242EC70.6010003@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Sep 25, 2013 at 04:00:16PM +0200, Paolo Bonzini wrote: > Il 25/09/2013 11:51, Gleb Natapov ha scritto: > > All exceptions should be checked for intercept during delivery to L2, > > but we check only #PF currently. Drop nested_run_pending while we are > > at it since exception cannot be injected during vmentry anyway. > > > > Signed-off-by: Gleb Natapov > > --- > > arch/x86/kvm/vmx.c | 8 +++----- > > 1 file changed, 3 insertions(+), 5 deletions(-) > > > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > > index 663bc5e..5bfa09d 100644 > > --- a/arch/x86/kvm/vmx.c > > +++ b/arch/x86/kvm/vmx.c > > @@ -1902,12 +1902,11 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu) > > * a #PF exception (this is the only case in which KVM injects a #PF when L2 > > * is running). > > */ > > -static int nested_pf_handled(struct kvm_vcpu *vcpu) > > +static int nested_ex_handled(struct kvm_vcpu *vcpu, unsigned nr) > > { > > struct vmcs12 *vmcs12 = get_vmcs12(vcpu); > > > > - /* TODO: also check PFEC_MATCH/MASK, not just EB.PF. */ > > Just one more question, why drop this comment? It doesn't seem > incorrect in the particular case where nr == PF_VECTOR. > I moved it to vmx_inject_page_fault_nested(). > > - if (!(vmcs12->exception_bitmap & (1u << PF_VECTOR))) > > + if (!(vmcs12->exception_bitmap & (1u << nr))) > > return 0; > > > > nested_vmx_vmexit(vcpu); > > @@ -1921,8 +1920,7 @@ static void vmx_queue_exception(struct kvm_vcpu *vcpu, unsigned nr, > > struct vcpu_vmx *vmx = to_vmx(vcpu); > > u32 intr_info = nr | INTR_INFO_VALID_MASK; > > > > - if (!reinject && nr == PF_VECTOR && is_guest_mode(vcpu) && > > - !vmx->nested.nested_run_pending && nested_pf_handled(vcpu)) > > + if (!reinject && is_guest_mode(vcpu) && nested_ex_handled(vcpu, nr)) > > return; > > > > if (has_error_code) { > > -- Gleb.