lkml.org 
[lkml]   [2020]   [Feb]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] KVM: x86/mmu: Avoid retpoline on ->page_fault() with TDP
From
Date
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?

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

\
 
 \ /
  Last update: 2020-02-12 12:55    [W:0.067 / U:0.880 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site