All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wanpeng Li <kernellwp@gmail.com>
To: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	kvm <kvm@vger.kernel.org>, Paolo Bonzini <pbonzini@redhat.com>,
	Wanpeng Li <wanpeng.li@hotmail.com>
Subject: Re: [PATCH v7 2/4] KVM: async_pf: Add L1 guest async_pf #PF vmexit handler
Date: Fri, 14 Jul 2017 09:40:03 +0800	[thread overview]
Message-ID: <CANRm+CzxufXDS0NszEo+PBfoivdhZfnTHwZLMVjq_Qvkzu3Jog@mail.gmail.com> (raw)
In-Reply-To: <20170713152921.GF3442@potion>

2017-07-13 23:29 GMT+08:00 Radim Krčmář <rkrcmar@redhat.com>:
> 2017-07-12 23:44+0200, Radim Krčmář:
>> 2017-06-28 20:01-0700, Wanpeng Li:
>> > From: Wanpeng Li <wanpeng.li@hotmail.com>
>> >
>> > This patch adds the L1 guest async page fault #PF vmexit handler, such
>> > #PF is converted into vmexit from L2 to L1 on #PF which is then handled
>> > by L1 similar to ordinary async page fault.
>> >
>> > Cc: Paolo Bonzini <pbonzini@redhat.com>
>> > Cc: Radim Krčmář <rkrcmar@redhat.com>
>> > Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
>> > ---
>>
>> This patch breaks SVM, so I've taken the series off kvm/queue for now;
>
> The error is triggered by 'WARN_ON_ONCE(tdp_enabled);', because
> pf_interception() handles both cases.  (The bizzare part is that it
> doesn't warn.)
>
> I think this hunk on top of the patch would be good.  It makes the

Thanks Radim! The work is really appreciated. :)

> WARN_ON_ONCE specific to VMX and also preserves the parameters that SVM
> had before.

I replace the tdp_enabled by enable_ept in VMX since there is a
warning: "tdp_enabled" in [kvm-intel.ko] undefined! Btw, I just sent
out v8, hope both
the v8 and vm86 stuff can catch the end of the merge window. :)

Regards,
Wanpeng Li

>
> (Passes basic tests, haven't done the nested async_pf test yet.)
>
>
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index f37c0307dcb0..338cb4c8cbb9 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -3782,17 +3782,16 @@ static bool try_async_pf(struct kvm_vcpu *vcpu, bool prefault, gfn_t gfn,
>  }
>
>  int kvm_handle_page_fault(struct kvm_vcpu *vcpu, u64 error_code,
> -                               u64 fault_address)
> +                               u64 fault_address, char *insn, int insn_len,
> +                               bool need_unprotect)
>  {
>         int r = 1;
>
>         switch (vcpu->arch.apf.host_apf_reason) {
>         default:
> -               /* TDP won't cause page fault directly */
> -               WARN_ON_ONCE(tdp_enabled);
>                 trace_kvm_page_fault(fault_address, error_code);
>
> -               if (kvm_event_needs_reinjection(vcpu))
> +               if (need_unprotect && kvm_event_needs_reinjection(vcpu))
>                         kvm_mmu_unprotect_page_virt(vcpu, fault_address);
>                 r = kvm_mmu_page_fault(vcpu, fault_address, error_code, NULL, 0);
>                 break;
> diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
> index 270d9adaa039..d7d248a000dd 100644
> --- a/arch/x86/kvm/mmu.h
> +++ b/arch/x86/kvm/mmu.h
> @@ -78,7 +78,8 @@ void kvm_init_shadow_ept_mmu(struct kvm_vcpu *vcpu, bool execonly,
>                              bool accessed_dirty);
>  bool kvm_can_do_async_pf(struct kvm_vcpu *vcpu);
>  int kvm_handle_page_fault(struct kvm_vcpu *vcpu, u64 error_code,
> -                               u64 fault_address);
> +                               u64 fault_address, char *insn, int insn_len,
> +                               bool need_unprotect);
>
>  static inline unsigned int kvm_mmu_available_pages(struct kvm *kvm)
>  {
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 659b610c4711..fb23497cf915 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -2123,7 +2123,9 @@ static int pf_interception(struct vcpu_svm *svm)
>         u64 fault_address = svm->vmcb->control.exit_info_2;
>         u64 error_code = svm->vmcb->control.exit_info_1;
>
> -       return kvm_handle_page_fault(&svm->vcpu, error_code, fault_address);
> +       return kvm_handle_page_fault(&svm->vcpu, error_code, fault_address,
> +                       svm->vmcb->control.insn_bytes,
> +                       svm->vmcb->control.insn_len, !npt_enabled);
>  }
>
>  static int db_interception(struct vcpu_svm *svm)
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index ab33eace4f66..2e8cfb2f1371 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -5699,7 +5699,10 @@ static int handle_exception(struct kvm_vcpu *vcpu)
>
>         if (is_page_fault(intr_info)) {
>                 cr2 = vmcs_readl(EXIT_QUALIFICATION);
> -               return kvm_handle_page_fault(vcpu, error_code, cr2);
> +               /* TDP won't cause page fault directly */
> +               WARN_ON_ONCE(!vcpu->arch.apf.host_apf_reason && tdp_enabled);
> +               return kvm_handle_page_fault(vcpu, error_code, cr2, NULL, 0,
> +                               true);
>         }
>
>         ex_no = intr_info & INTR_INFO_VECTOR_MASK;

  reply	other threads:[~2017-07-14  1:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-29  3:01 [PATCH v7 0/4] KVM: async_pf: Fix async pf exception injection Wanpeng Li
2017-06-29  3:01 ` [PATCH v7 1/4] KVM: x86: Simple kvm_x86_ops->queue_exception parameter Wanpeng Li
2017-06-29  3:01 ` [PATCH v7 2/4] KVM: async_pf: Add L1 guest async_pf #PF vmexit handler Wanpeng Li
2017-07-12 21:44   ` Radim Krčmář
2017-07-13  1:34     ` Wanpeng Li
2017-07-13 15:29     ` Radim Krčmář
2017-07-14  1:40       ` Wanpeng Li [this message]
2017-06-29  3:02 ` [PATCH v7 3/4] KVM: async_pf: Force a nested vmexit if the injected #PF is async_pf Wanpeng Li
2017-06-29  3:02 ` [PATCH v7 4/4] KVM: async_pf: Let host know whether the guest support delivery async_pf as #PF vmexit Wanpeng Li
2017-06-29  7:13 ` [PATCH v7 0/4] KVM: async_pf: Fix async pf exception injection Wanpeng Li
2017-06-29 12:15   ` 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=CANRm+CzxufXDS0NszEo+PBfoivdhZfnTHwZLMVjq_Qvkzu3Jog@mail.gmail.com \
    --to=kernellwp@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.