Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1675707
| From | Paolo Bonzini <pbonzini@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v5 2/4] KVM: async_pf: Add L1 guest async_pf #PF vmexit handler |
| Date | 2017-06-27 15:40 +0200 |
| Message-ID | <tWYSK-18m-27@gated-at.bofh.it> (permalink) |
| References | <tWNND-1Pa-7@gated-at.bofh.it> <tWNND-1Pa-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 27/06/2017 03:46, Wanpeng Li wrote:
> 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>
> ---
> arch/x86/kvm/vmx.c | 34 ++++++++++++++++++++++++++++------
> 1 file changed, 28 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index df825bb..f533cc1 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -616,6 +616,7 @@ struct vcpu_vmx {
> bool emulation_required;
>
> u32 exit_reason;
> + u32 apf_reason;
Can you instead of move vcpu_svm's apf_reason field to kvm_vcpu_arch?
(e.g. vcpu->arch.apf.host_apf_reason)?
> /* Posted interrupt descriptor */
> struct pi_desc pi_desc;
> @@ -5648,14 +5649,31 @@ static int handle_exception(struct kvm_vcpu *vcpu)
> }
>
> if (is_page_fault(intr_info)) {
> - /* EPT won't cause page fault directly */
> - BUG_ON(enable_ept);
> cr2 = vmcs_readl(EXIT_QUALIFICATION);
> - trace_kvm_page_fault(cr2, error_code);
> + switch (vmx->apf_reason) {
> + default:
> + /* EPT won't cause page fault directly */
> + BUG_ON(enable_ept);
> + trace_kvm_page_fault(cr2, error_code);
>
> - if (kvm_event_needs_reinjection(vcpu))
> - kvm_mmu_unprotect_page_virt(vcpu, cr2);
> - return kvm_mmu_page_fault(vcpu, cr2, error_code, NULL, 0);
> + if (kvm_event_needs_reinjection(vcpu))
> + kvm_mmu_unprotect_page_virt(vcpu, cr2);
> + return kvm_mmu_page_fault(vcpu, cr2, error_code, NULL, 0);
> + break;
> + case KVM_PV_REASON_PAGE_NOT_PRESENT:
> + vmx->apf_reason = 0;
> + local_irq_disable();
> + kvm_async_pf_task_wait(cr2);
> + local_irq_enable();
> + break;
> + case KVM_PV_REASON_PAGE_READY:
> + vmx->apf_reason = 0;
> + local_irq_disable();
> + kvm_async_pf_task_wake(cr2);
> + local_irq_enable();
> + break;
> + }
> + return 0;
> }
This code can be moved to a common function
int kvm_handle_page_fault(struct kvm_vcpu *vcpu, u64 error_code,
u64 fault_address);
in mmu.c. It can be used by vmx.c here and in svm.c's pf_interception.
You can change "enable_ept" to "tdp_enabled" (but please make that a
WARN_ON_ONCE, too).
Thanks,
Paolo
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v5 0/4] KVM: async_pf: Fix async pf exception injection Wanpeng Li <kernellwp@gmail.com> - 2017-06-27 03:50 +0200
[PATCH v5 4/4] KVM: async_pf: Let host know whether the guest support delivery async_pf as #PF vmexit Wanpeng Li <kernellwp@gmail.com> - 2017-06-27 03:50 +0200
Re: [PATCH v5 4/4] KVM: async_pf: Let host know whether the guest support delivery async_pf as #PF vmexit Paolo Bonzini <pbonzini@redhat.com> - 2017-06-27 15:30 +0200
Re: [PATCH v5 4/4] KVM: async_pf: Let host know whether the guest support delivery async_pf as #PF vmexit Wanpeng Li <kernellwp@gmail.com> - 2017-06-28 00:50 +0200
[PATCH v5 2/4] KVM: async_pf: Add L1 guest async_pf #PF vmexit handler Wanpeng Li <kernellwp@gmail.com> - 2017-06-27 03:50 +0200
Re: [PATCH v5 2/4] KVM: async_pf: Add L1 guest async_pf #PF vmexit handler Paolo Bonzini <pbonzini@redhat.com> - 2017-06-27 15:40 +0200
Re: [PATCH v5 2/4] KVM: async_pf: Add L1 guest async_pf #PF vmexit handler Wanpeng Li <kernellwp@gmail.com> - 2017-06-28 00:50 +0200
csiph-web