RISC-V: KVM: fix __le64 type assignments
Subsystems (3)
PATCH 1/1 RISC-V: KVM: fix __le64 type assignments
The two swaps from le32/le64 in arch/riscv/include/asm/kvm_nacl.h are generating a number of type assingment warnings in sparse, so fix by using __force and assuming the code is correct.
Fixes a number of:
arch/riscv/kvm/vcpu.c:371:21: warning: cast to restricted __le64 arch/riscv/kvm/vcpu.c:374:16: warning: cast to restricted __le64 arch/riscv/kvm/vcpu.c:586:17: warning: incorrect type in assignment (different base types)arch/riscv/kvm/vcpu.c:586:17: expected unsigned longarch/riscv/kvm/vcpu.c:586:17: got restricted __le64 [usertype]
--- arch/riscv/include/asm/kvm_nacl.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/riscv/include/asm/kvm_nacl.h +4 -4
@@ -58,11 +58,11 @@ void kvm_riscv_nacl_exit(void);int kvm_riscv_nacl_init (void );#ifdef CONFIG_32BIT -#define lelong_to_cpu (__x) le32_to_cpu(__x) -#define cpu_to_lelong (__x) cpu_to_le32(__x) +#define lelong_to_cpu (__x) le32_to_cpu((__force __le32)__x) +#define cpu_to_lelong (__x) (__force unsigned long)cpu_to_le32(__x)#else -#define lelong_to_cpu (__x) le64_to_cpu(__x) -#define cpu_to_lelong (__x) cpu_to_le64(__x) +#define lelong_to_cpu (__x) le64_to_cpu((__force __le64)__x) +#define cpu_to_lelong (__x) (__force unsigned long)cpu_to_le64(__x)#endif #define nacl_shmem () \
Signature · 1 line
2.37.2.352.g3c44437643
Anup Patel
maintainerQuoted 3 lines · Ben Dooks
The two swaps from le32/le64 in
arch/riscv/include/asm/kvm_nacl.hare generating a number of type assingment warnings in sparse, so
s/assingment/assignment/
Quoted 3 lines
fix by using
__forceand assuming the code is correct.Fixes a number of:
s/... number of:/... number of sparse warnings:/
Quoted 7 lines
arch/riscv/kvm/vcpu.c:371:21: warning: cast to restricted__le64arch/riscv/kvm/vcpu.c:374:16: warning: cast to restricted__le64arch/riscv/kvm/vcpu.c:586:17: warning: incorrect type in assignment (different base types)arch/riscv/kvm/vcpu.c:586:17: expected unsigned longarch/riscv/kvm/vcpu.c:586:17: got restricted__le64[usertype]
Please add a Fixes tag.
Quoted 26 lines
Signed-off-by Ben Dooks <[email protected]>--- arch/riscv/include/asm/kvm_nacl.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)arch/riscv/include/asm/kvm_nacl.h +4
-5@@ -58,11 +58,11 @@ void kvm_riscv_nacl_exit(void);int kvm_riscv_nacl_init (void );#ifdef CONFIG_32BIT -#define lelong_to_cpu (__x) le32_to_cpu(__x) -#define cpu_to_lelong (__x) cpu_to_le32(__x) +#define lelong_to_cpu (__x) le32_to_cpu((__force __le32)__x) +#define cpu_to_lelong (__x) (__force unsigned long)cpu_to_le32(__x)#else -#define lelong_to_cpu (__x) le64_to_cpu(__x) -#define cpu_to_lelong (__x) cpu_to_le64(__x) +#define lelong_to_cpu (__x) le64_to_cpu((__force __le64)__x) +#define cpu_to_lelong (__x) (__force unsigned long)cpu_to_le64(__x)#endif #define nacl_shmem () \ --
Quoted 2 lines
2.37.2.352.g3c44437643
Regards,
Anup