Skip to contentSkip to conversation

KVM: arm64: Mark set_sysreg_masks() as inline to avoid build failure

PATCH Applied Marc Zyngier 3 participants 3 messages Nov 20, 2024 – Nov 21, 2024

Subsystems (2)
lore
Share & tools
lore

Marc Zyngier

author maintainer
#0 lore raw

PATCH 1/1 KVM: arm64: Mark set_sysreg_masks() as inline to avoid build failure

When compiling with CONFIG_CC_OPTIMIZE_FOR_SIZE=y, set_sysreg_masks() fails to compile thanks to:

	BUILD_BUG_ON(!__builtin_constant_p(sr));

as the compiler doesn't identify sr as a constant, despite all the callers passing constants.

Fix the issue by always inlining this function, which allows GCC to do the right thing.

Fixes a0162020095e2 ("KVM: arm64: Extend masking facility to arbitrary registers")
---
 arch/arm64/kvm/nested.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/nested.c +1 -1
index aeaa6017ffd89..9b36218b48def 100644
@@ -951,7 +951,7 @@ u64 kvm_vcpu_apply_reg_masks(const struct kvm_vcpu *vcpu,
 	return v;
 }
 
-static void set_sysreg_masks(struct kvm *kvm, int sr, u64 res0, u64 res1)
+static __always_inline void set_sysreg_masks(struct kvm *kvm, int sr, u64 res0, u64 res1)
 {
 	int i = sr - __SANITISED_REG_START__;
 
Signature · 1 line
2.39.2
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Marc Zyngier

When compiling with CONFIG_CC_OPTIMIZE_FOR_SIZE=y, set_sysreg_masks() fails to compile thanks to:

	BUILD_BUG_ON(!__builtin_constant_p(sr));

as the compiler doesn't identify sr as a constant, despite all the callers passing constants.

Fix the issue by always inlining this function, which allows GCC to do the right thing.

Fixes a0162020095e2 ("KVM: arm64: Extend masking facility to arbitrary registers")
---
 arch/arm64/kvm/nested.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/nested.c +0 -0
index aeaa6017ffd89..9b36218b48def 100644

arch/arm64/kvm/nested.c u64 kvm_vcpu_apply_reg_masks(const struct kvm_vcpu *vcpu, · line 957

Quoted 8 lines
arch/arm64/kvm/nested.c +1 -1
@@ -951,7 +951,7 @@ u64 kvm_vcpu_apply_reg_masks(const struct kvm_vcpu *vcpu,
 	return v;
 }
 
-static void set_sysreg_masks(struct kvm *kvm, int sr, u64 res0, u64 res1)
+static __always_inline void set_sysreg_masks(struct kvm *kvm, int sr, u64 res0, u64 res1)
 {
 	int i = sr - __SANITISED_REG_START__;
 
Applied
#2 lore raw
In reply to Marc Zyngier
Quoted 9 lines · Marc Zyngier

When compiling with CONFIG_CC_OPTIMIZE_FOR_SIZE=y, set_sysreg_masks() fails to compile thanks to:

	BUILD_BUG_ON(!__builtin_constant_p(sr));

as the compiler doesn't identify sr as a constant, despite all the callers passing constants.

[...]

Applied to fixes, thanks!

[1/1] KVM: arm64: Mark set_sysreg_masks() as inline to avoid build failure

      https://git.kernel.org/kvmarm/kvmarm/c/0f3a0f23f562

--
Best,
Oliver