[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2652c27e-ce8c-eb40-1979-9fe732aa9085@redhat.com>
Date: Tue, 8 Mar 2022 17:21:09 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
dmatlack@...gle.com
Subject: Re: [PATCH v2 01/25] KVM: x86/mmu: avoid indirect call for get_cr3
On 3/8/22 17:16, Sean Christopherson wrote:
>
>> +static inline unsigned long kvm_mmu_get_guest_pgd(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu)
> Wrap the params, no reason to make this line so long.
>
>> +{
>> +#ifdef CONFIG_RETPOLINE
>> + if (mmu->get_guest_pgd == kvm_get_guest_cr3)
>> + return kvm_read_cr3(vcpu);
> This is unnecessarily fragile and confusing at first glance. Compilers are smart
> enough to generate a non-inline version of functions if they're used for function
> pointers, while still inlining where appropriate. In other words, just drop
> kvm_get_guest_cr3() entirely, a al get_pdptr => kvm_pdptr_read().
Unfortunately this isn't entirely true. The function pointer will not
match between compilation units, in this case between the one that calls
kvm_mmu_get_guest_pgd and the one that assigned kvm_read_cr3 to the
function pointer.
Paolo
Powered by blists - more mailing lists