Skip to content

Commit b7bce57

Browse files
BenjaminGrayNp1mpe
authored andcommitted
powerpc/kvm: Force cast endianness of KVM shared regs
Sparse reports endianness mismatches in the KVM shared regs getter and setter helpers. This code has dynamic endianness behind a safe interface, so a force is warranted here to tell sparse this is OK. Signed-off-by: Benjamin Gray <bgray@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20231011053711.93427-8-bgray@linux.ibm.com
1 parent 4766522 commit b7bce57

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/powerpc/include/asm/kvm_ppc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -981,18 +981,18 @@ static inline u##size kvmppc_get_##reg(struct kvm_vcpu *vcpu) \
981981
if (iden) \
982982
WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, iden) < 0); \
983983
if (kvmppc_shared_big_endian(vcpu)) \
984-
return be##size##_to_cpu(vcpu->arch.shared->reg); \
984+
return be##size##_to_cpu((__be##size __force)vcpu->arch.shared->reg); \
985985
else \
986-
return le##size##_to_cpu(vcpu->arch.shared->reg); \
986+
return le##size##_to_cpu((__le##size __force)vcpu->arch.shared->reg); \
987987
} \
988988

989989
#define KVMPPC_VCPU_SHARED_REGS_ACCESSOR_SET(reg, size, iden) \
990990
static inline void kvmppc_set_##reg(struct kvm_vcpu *vcpu, u##size val) \
991991
{ \
992992
if (kvmppc_shared_big_endian(vcpu)) \
993-
vcpu->arch.shared->reg = cpu_to_be##size(val); \
993+
vcpu->arch.shared->reg = (u##size __force)cpu_to_be##size(val); \
994994
else \
995-
vcpu->arch.shared->reg = cpu_to_le##size(val); \
995+
vcpu->arch.shared->reg = (u##size __force)cpu_to_le##size(val); \
996996
\
997997
if (iden) \
998998
kvmhv_nestedv2_mark_dirty(vcpu, iden); \

0 commit comments

Comments
 (0)