From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932239AbdGXNg6 (ORCPT ); Mon, 24 Jul 2017 09:36:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44884 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932165AbdGXNgP (ORCPT ); Mon, 24 Jul 2017 09:36:15 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5F1D27F6A5 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=pbonzini@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5F1D27F6A5 Subject: Re: [PATCH] KVM: nVMX: consult PFER_MASK and PFER_MATCH before nested vmexit if inject #PF To: Wanpeng Li , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Wanpeng Li References: <1500771954-3979-1-git-send-email-wanpeng.li@hotmail.com> From: Paolo Bonzini Message-ID: <8515ff0e-a9f3-f6f2-47db-d475b0de5c45@redhat.com> Date: Mon, 24 Jul 2017 15:36:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1500771954-3979-1-git-send-email-wanpeng.li@hotmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 24 Jul 2017 13:36:14 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/07/2017 03:05, Wanpeng Li wrote: > From: Wanpeng Li > > When generating #PF VM-exit, check equality: > (PFEC & PFEC_MASK) == PFEC_MATCH > If there is equality, the 14 bit of exception bitmap is used to take decision > about generating #PF VM-exit. If there is inequality, inverted 14 bit is used. > > Reported-by: Jim Mattson > Cc: Paolo Bonzini > Cc: Radim Krčmář > Signed-off-by: Wanpeng Li > --- > arch/x86/kvm/vmx.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 29fd8af..8a213f2 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -2429,6 +2429,8 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu) > vmx_set_interrupt_shadow(vcpu, 0); > } > > +static bool nested_vmx_is_page_fault_vmexit(struct vmcs12 *vmcs12, u16 error_code); > + > /* > * KVM wants to inject page-faults which it got to the guest. This function > * checks whether in a nested guest, we need to inject them to L1 or L2. > @@ -2442,6 +2444,10 @@ static int nested_vmx_check_exception(struct kvm_vcpu *vcpu) > (nr == PF_VECTOR && vcpu->arch.exception.nested_apf))) > return 0; > > + if (nr == PF_VECTOR && !vcpu->arch.exception.nested_apf && > + !nested_vmx_is_page_fault_vmexit(vmcs12, vcpu->arch.exception.error_code)) > + return 0; This is wrong, the check must replace "(vmcs12->exception_bitmap & (1u << nr)" if nr == PF_VECTOR. Paolo > if (vcpu->arch.exception.nested_apf) { > vmcs_write32(VM_EXIT_INTR_ERROR_CODE, vcpu->arch.exception.error_code); > nested_vmx_vmexit(vcpu, EXIT_REASON_EXCEPTION_NMI, >