Re: [PATCH] KVM: x86/mmu: Avoid retpoline on ->page_fault() with TDP
From: Vitaly Kuznetsov
Date: Fri Feb 07 2020 - 04:29:24 EST
Sean Christopherson <sean.j.christopherson@xxxxxxxxx> writes:
> Wrap calls to ->page_fault() with a small shim to directly invoke the
> TDP fault handler when the kernel is using retpolines and TDP is being
> used. Denote the TDP fault handler by nullifying mmu->page_fault, and
> annotate the TDP path as likely to coerce the compiler into preferring
> the TDP path.
>
> Rename tdp_page_fault() to kvm_tdp_page_fault() as it's exposed outside
> of mmu.c to allow inlining the shim.
>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
> ---
Out of pure curiosity, if we do something like
if (vcpu->arch.mmu->page_fault == tdp_page_fault)
tdp_page_fault(...)
else if (vcpu->arch.mmu->page_fault == nonpaging_page_fault)
nonpaging_page_fault(...)
...
we also defeat the retpoline, right? Should we use this technique
... everywhere? :-)
--
Vitaly