Re: [PATCH v2 2/3] KVM: x86: introduce definitions to support static calls for kvm_x86_ops

Peter Zijlstra
2021-01-15T09:29:02Z

On Thu, Jan 14, 2021 at 10:27:55PM -0500, Jason Baron wrote:
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 3f7c1fc..c21927f 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -113,6 +113,15 @@ static int sync_regs(struct kvm_vcpu *vcpu);
> struct kvm_x86_ops kvm_x86_ops __read_mostly;
> EXPORT_SYMBOL_GPL(kvm_x86_ops);
>
> +#define KVM_X86_OP(func) \
> + DEFINE_STATIC_CALL_NULL(kvm_x86_##func, \
> + *(((struct kvm_x86_ops *)0)->func));
> +#define KVM_X86_OP_NULL KVM_X86_OP
> +#include <asm/kvm-x86-ops.h>
> +EXPORT_STATIC_CALL_GPL(kvm_x86_get_cs_db_l_bits);
> +EXPORT_STATIC_CALL_GPL(kvm_x86_cache_reg);
> +EXPORT_STATIC_CALL_GPL(kvm_x86_tlb_flush_current);

Would something like:

https://lkml.kernel.org/r/20201110103909.GD2594@hirez.programming.kicks-ass.net

Be useful? That way modules can call the static_call() but not change
it.