]> Git Repo - linux.git/commitdiff
powerpc/kvm: Force cast endianness of KVM shared regs
authorBenjamin Gray <[email protected]>
Wed, 11 Oct 2023 05:37:06 +0000 (16:37 +1100)
committerMichael Ellerman <[email protected]>
Thu, 19 Oct 2023 06:15:39 +0000 (17:15 +1100)
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 <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
Link: https://msgid.link/[email protected]
arch/powerpc/include/asm/kvm_ppc.h

index db8bfaaa4536131a33f071d8bb9e0b0918ec6905..3281215097cc63fe10b507abb84373b0ffbad45a 100644 (file)
@@ -981,18 +981,18 @@ static inline u##size kvmppc_get_##reg(struct kvm_vcpu *vcpu)             \
        if (iden)                                                       \
                WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, iden) < 0);  \
        if (kvmppc_shared_big_endian(vcpu))                             \
-              return be##size##_to_cpu(vcpu->arch.shared->reg);        \
+               return be##size##_to_cpu((__be##size __force)vcpu->arch.shared->reg);   \
        else                                                            \
-              return le##size##_to_cpu(vcpu->arch.shared->reg);        \
+               return le##size##_to_cpu((__le##size __force)vcpu->arch.shared->reg);   \
 }                                                                      \
 
 #define KVMPPC_VCPU_SHARED_REGS_ACCESSOR_SET(reg, size, iden)          \
 static inline void kvmppc_set_##reg(struct kvm_vcpu *vcpu, u##size val)        \
 {                                                                      \
        if (kvmppc_shared_big_endian(vcpu))                             \
-              vcpu->arch.shared->reg = cpu_to_be##size(val);           \
+               vcpu->arch.shared->reg = (u##size __force)cpu_to_be##size(val); \
        else                                                            \
-              vcpu->arch.shared->reg = cpu_to_le##size(val);           \
+               vcpu->arch.shared->reg = (u##size __force)cpu_to_le##size(val); \
                                                                        \
        if (iden)                                                       \
                kvmhv_nestedv2_mark_dirty(vcpu, iden);                  \
This page took 0.06081 seconds and 4 git commands to generate.