Skip to contentSkip to conversation

KVM: x86: Fix function address when kvm_x86_ops.func is NULL

PATCH In review Like Xu 3 participants 4 messages Feb 22, 2022

Subsystems (3)
lore
Share & tools
lore

Like Xu

author
#0 lore raw

PATCH 1/1 KVM: x86: Fix function address when kvm_x86_ops.func is NULL

From: Like Xu <[email protected]>

Fix the function address for __static_call_return0() which is used by static_call_update() when a func in struct kvm_x86_ops is NULL.

Fixes 5be2226f417d ("KVM: x86: allow defining return-0 static calls")
---
 arch/x86/include/asm/kvm_host.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/kvm_host.h +1 -1
index 713e08f62385..312f5ee19514 100644
@@ -1548,7 +1548,7 @@ static inline void kvm_ops_static_call_update(void)
 #define KVM_X86_OP_OPTIONAL __KVM_X86_OP
 #define KVM_X86_OP_OPTIONAL_RET0(func) \
 	static_call_update(kvm_x86_##func, kvm_x86_ops.func ? : \
-			   (void *) __static_call_return0);
+			   (void *)&__static_call_return0);
 #include <asm/kvm-x86-ops.h>
 #undef __KVM_X86_OP
 }
Signature · 1 line
2.35.0
maintainer
#1 lore raw
Quoted 7 lines · Like Xu

From: Like Xu <[email protected]>

Fix the function address for __static_call_return0() which is used by static_call_update() when a func in struct kvm_x86_ops is NULL.

Fixes 5be2226f417d ("KVM: x86: allow defining return-0 static calls")

Sorry for the stupid question, but what breaks?

Paolo

Quoted 17 lines
---
  arch/x86/include/asm/kvm_host.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/kvm_host.h +1 -1
index 713e08f62385..312f5ee19514 100644
@@ -1548,7 +1548,7 @@ static inline void kvm_ops_static_call_update(void)
  #define KVM_X86_OP_OPTIONAL __KVM_X86_OP
  #define KVM_X86_OP_OPTIONAL_RET0(func) \
  	static_call_update(kvm_x86_##func, kvm_x86_ops.func ? : \
-			   (void *) __static_call_return0);
+			   (void *)&__static_call_return0);
  #include <asm/kvm-x86-ops.h>
  #undef __KVM_X86_OP
  }
author
#2 lore raw
Quoted 10 lines · Paolo Bonzini
Quoted 7 lines · Like Xu

From: Like Xu <[email protected]>

Fix the function address for __static_call_return0() which is used by static_call_update() when a func in struct kvm_x86_ops is NULL.

Fixes 5be2226f417d ("KVM: x86: allow defining return-0 static calls")

Sorry for the stupid question, but what breaks?

Although they are numerically the same, I suppose we should use the & operator here, as in the other cases where __static_call_return0 is used.

What's more, Clang complains about the KVM_X86_OP_OPTIONAL_RET0 change:

./arch/x86/include/asm/kvm-x86-ops.h:108:1: warning: pointer type mismatch \
	('bool (*)(struct kvm_vcpu *)' (aka '_Bool (*)(struct kvm_vcpu *)') and 'void *') \
	[-Wpointer-type-mismatch]

and more warnings from [-Wpointer-type-mismatch]

Does it help you ?

Quoted 21 lines

Paolo

Quoted 17 lines

---
  arch/x86/include/asm/kvm_host.h | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/kvm_host.h +1 -1
index 713e08f62385..312f5ee19514 100644
@@ -1548,7 +1548,7 @@ static inline void kvm_ops_static_call_update(void)
   #define KVM_X86_OP_OPTIONAL __KVM_X86_OP
   #define KVM_X86_OP_OPTIONAL_RET0(func) \
       static_call_update(kvm_x86_##func, kvm_x86_ops.func ? : \
-               (void *) __static_call_return0);
+               (void *)&__static_call_return0);
   #include <asm/kvm-x86-ops.h>
   #undef __KVM_X86_OP
   }
#3 lore raw
Quoted 7 lines · Like Xu
Quoted 6 lines · Paolo Bonzini
Quoted 5 lines · Like Xu

From: Like Xu <[email protected]>

Fix the function address for __static_call_return0() which is used by static_call_update() when a func in struct kvm_x86_ops is NULL.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Fixes 5be2226f417d ("KVM: x86: allow defining return-0 static calls")

Sorry for the stupid question, but what breaks?

Although they are numerically the same, I suppose we should use the & operator here, as in the other cases where __static_call_return0 is used.

Meh, IMO all the other instances are weird for adding the "&".