mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Wanpeng Li <kernellwp@gmail.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
	"Wanpeng Li" <wanpeng.li@hotmail.com>
Subject: Re: [PATCH] KVM: nVMX: consult PFER_MASK and PFER_MATCH before nested vmexit if inject #PF
Date: Mon, 24 Jul 2017 15:36:11 +0200	[thread overview]
Message-ID: <8515ff0e-a9f3-f6f2-47db-d475b0de5c45@redhat.com> (raw)
In-Reply-To: <1500771954-3979-1-git-send-email-wanpeng.li@hotmail.com>

On 23/07/2017 03:05, Wanpeng Li wrote:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
> 
> 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 <jmattson@google.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
>  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,
> 

  reply	other threads:[~2017-07-24 13:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-23  1:05 Wanpeng Li
2017-07-24 13:36 ` Paolo Bonzini [this message]
2017-07-24 13:57   ` Wanpeng Li
2017-07-24 14:28     ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8515ff0e-a9f3-f6f2-47db-d475b0de5c45@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kernellwp@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rkrcmar@redhat.com \
    --cc=wanpeng.li@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®