Re: [PATCH] KVM: x86/mmu: Avoid retpoline on ->page_fault() with TDP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 12, 2020 at 12:55:09PM +0100, Paolo Bonzini wrote:
> On 07/02/20 16:55, Sean Christopherson wrote:
> > It becomes a matter of weighing the maintenance cost and robustness against
> > the performance benefits.  For the TDP case, amost no one (that cares about
> > performance) uses shadow paging, the change is very explicit, tiny and
> > isolated, and TDP page fault are a hot path, e.g. when booting the VM.
> > I.e. low maintenance overhead, still robust, and IMO worth the shenanigans.
> 
> The "NULL" trick does not seem needed though.  Any objections to this?

Nope, no objections.

> diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
> index 9277ee8a54a5..a647601c9e1c 100644
> --- a/arch/x86/kvm/mmu.h
> +++ b/arch/x86/kvm/mmu.h
> @@ -109,7 +109,7 @@ static inline int kvm_mmu_do_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
>  					u32 err, bool prefault)
>  {
>  #ifdef CONFIG_RETPOLINE
> -	if (likely(!vcpu->arch.mmu->page_fault))
> +	if (likely(vcpu->arch.mmu->page_fault == kvm_tdp_page_fault))
>  		return kvm_tdp_page_fault(vcpu, cr2_or_gpa, err, prefault);
>  #endif
>  	return vcpu->arch.mmu->page_fault(vcpu, cr2_or_gpa, err, prefault);
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 5267f1440677..87e9ba27ada1 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -4925,12 +4925,7 @@ static void init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
>  		return;
>  
>  	context->mmu_role.as_u64 = new_role.as_u64;
> -#ifdef CONFIG_RETPOLINE
> -	/* Nullify ->page_fault() to use direct kvm_tdp_page_fault() call. */
> -	context->page_fault = NULL;
> -#else
>  	context->page_fault = kvm_tdp_page_fault;
> -#endif
>  	context->sync_page = nonpaging_sync_page;
>  	context->invlpg = nonpaging_invlpg;
>  	context->update_pte = nonpaging_update_pte;
> 
> Paolo
> 



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux