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

Sean Christopherson
2021-01-13T17:18:17Z

On Wed, Jan 13, 2021, Paolo Bonzini wrote:
> If you need to choose between DECLARE_STATIC_CALL_NULL and
> DECLARE_STATIC_CALL, you can have kvm-x86-ops.h use one of two macros
> KVM_X86_OP_NULL and KVM_X86_OP.
>
> #define KVM_X86_OP(func) \
> DECLARE_STATIC_CALL(kvm_x86_##func, \
> *(((struct kvm_x86_ops *)0)->func));
>
> #define KVM_X86_OP_NULL(func) \
> DECLARE_STATIC_CALL_NULL(kvm_x86_##func, \

Gah, DECLARE_STATIC_CALL_NULL doesn't exist, though it's referenced in a comment.
I assume these should be s/DECLARE/DEFINE? I haven't fully grokked the static
call code yet...

> *(((struct kvm_x86_ops *)0)->func));
>
> #include <asm/kvm-x86-ops.h>
>
> ...
>
> #define KVM_X86_OP(func) \
> static_call_update(kvm_x86_##func, kvm_x86_ops.func)
> #define KVM_X86_OP_NULL(func) \
> static_call_update(kvm_x86_##func, kvm_x86_ops.func)
> #include <asm/kvm-x86-ops.h>
>
> In that case vmx.c and svm.c could define KVM_X86_OP_NULL to an empty string
> and list the optional callbacks manually.
>
> Paolo
>