[PATCH 3/5] KVM: x86: warn on incorrectly NULL static calls
From: Paolo Bonzini
Date: Wed Feb 02 2022 - 13:18:23 EST
Use the newly corrected KVM_X86_OP annotations to warn about possible
NULL pointer dereferences as soon as the vendor module is loaded.
Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
---
arch/x86/include/asm/kvm_host.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index c371ee7e45f7..61faeb57889c 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1544,9 +1544,10 @@ extern struct kvm_x86_ops kvm_x86_ops;
static inline void kvm_ops_static_call_update(void)
{
-#define KVM_X86_OP(func) \
+#define KVM_X86_OP_NULL(func) \
static_call_update(kvm_x86_##func, kvm_x86_ops.func);
-#define KVM_X86_OP_NULL KVM_X86_OP
+#define KVM_X86_OP(func) \
+ WARN_ON(!kvm_x86_ops.func); KVM_X86_OP_NULL(func)
#include <asm/kvm-x86-ops.h>
}
--
2.31.1