EXPORT_SYMBOL_FOR_KVM() exists to export symbols to KVM modules. Static calls need the same treatment when the core kernel defines a static_call that KVM needs access to (e.g. from a VM-exit path). Define EXPORT_STATIC_CALL_FOR_KVM() as the static_call analogue of EXPORT_SYMBOL_FOR_KVM(). The same three-way logic applies: - KVM_SUB_MODULES defined: export to "kvm," plus all sub-modules - KVM=m, no sub-modules: export to "kvm" only - KVM built-in: no export needed (noop) As with EXPORT_SYMBOL_FOR_KVM(), allow architectures to override both macros (e.g. to suppress the export when kvm.ko itself will not be built despite CONFIG_KVM=m). Add the x86 no-op overrides in arch/x86/include/asm/kvm_types.h for that case. To keep the pair in sync, EXPORT_STATIC_CALL_FOR_KVM() is defined inside the EXPORT_SYMBOL_FOR_KVM #ifndef block; an arch that defines EXPORT_SYMBOL_FOR_KVM must also define EXPORT_STATIC_CALL_FOR_KVM or the build will fail with a compile-time error. As with EXPORT_SYMBOL_FOR_KVM(), allow architectures to override EXPORT_STATIC_CALL_FOR_KVM definition (e.g. to suppress the export when kvm.ko itself will not be built despite CONFIG_KVM=m). Add the x86 no-op override in arch/x86/include/asm/kvm_types.h for that case. Architectures must also define EXPORT_STATIC_CALL_FOR_KVM when they define EXPORT_SYMBOL_FOR_KVM. Suggested-by: Sean Christopherson Acked-by: Sean Christopherson Signed-off-by: Pawan Gupta --- arch/x86/include/asm/kvm_types.h | 1 + include/linux/kvm_types.h | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_types.h b/arch/x86/include/asm/kvm_types.h index d7c704ed1be9..bceeaed2940e 100644 --- a/arch/x86/include/asm/kvm_types.h +++ b/arch/x86/include/asm/kvm_types.h @@ -15,6 +15,7 @@ * at least one vendor module is enabled. */ #define EXPORT_SYMBOL_FOR_KVM(symbol) +#define EXPORT_STATIC_CALL_FOR_KVM(symbol) #endif #define KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE 40 diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h index a568d8e6f4e8..be602d3f287e 100644 --- a/include/linux/kvm_types.h +++ b/include/linux/kvm_types.h @@ -13,6 +13,8 @@ EXPORT_SYMBOL_FOR_MODULES(symbol, __stringify(KVM_SUB_MODULES)) #define EXPORT_SYMBOL_FOR_KVM(symbol) \ EXPORT_SYMBOL_FOR_MODULES(symbol, "kvm," __stringify(KVM_SUB_MODULES)) +#define EXPORT_STATIC_CALL_FOR_KVM(symbol) \ + EXPORT_STATIC_CALL_FOR_MODULES(symbol, "kvm," __stringify(KVM_SUB_MODULES)) #else #define EXPORT_SYMBOL_FOR_KVM_INTERNAL(symbol) /* @@ -23,11 +25,17 @@ #ifndef EXPORT_SYMBOL_FOR_KVM #if IS_MODULE(CONFIG_KVM) #define EXPORT_SYMBOL_FOR_KVM(symbol) EXPORT_SYMBOL_FOR_MODULES(symbol, "kvm") +#define EXPORT_STATIC_CALL_FOR_KVM(symbol) EXPORT_STATIC_CALL_FOR_MODULES(symbol, "kvm") #else #define EXPORT_SYMBOL_FOR_KVM(symbol) +#define EXPORT_STATIC_CALL_FOR_KVM(symbol) #endif /* IS_MODULE(CONFIG_KVM) */ -#endif /* EXPORT_SYMBOL_FOR_KVM */ +#else +#ifndef EXPORT_STATIC_CALL_FOR_KVM +#error Must #define EXPORT_STATIC_CALL_FOR_KVM if #defining EXPORT_SYMBOL_FOR_KVM #endif +#endif /* EXPORT_SYMBOL_FOR_KVM */ +#endif /* KVM_SUB_MODULES */ #ifndef __ASSEMBLER__ -- 2.34.1