]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: Add endian casting to kvm_swap_s[12]_desc()
authorMarc Zyngier <maz@kernel.org>
Tue, 25 Nov 2025 20:48:48 +0000 (20:48 +0000)
committerOliver Upton <oupton@kernel.org>
Mon, 1 Dec 2025 08:44:02 +0000 (00:44 -0800)
Keep sparse quiet by explicitly casting endianness conversion
when swapping S1 and S2 descriptors.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202511260246.JQDGsQKa-lkp@intel.com/
Closes: https://lore.kernel.org/oe-kbuild-all/202511260344.9XehvH5Q-lkp@intel.com/
Fixes: c59ca4b5b0c3f ("KVM: arm64: Implement HW access flag management in stage-1 SW PTW")
Fixes: 39db933ba67f8 ("KVM: arm64: nv: Implement HW access flag management in stage-2 SW PTW")
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://msgid.link/20251125204848.1136383-1-maz@kernel.org
Signed-off-by: Oliver Upton <oupton@kernel.org>
arch/arm64/kvm/at.c
arch/arm64/kvm/nested.c

index f774a02d9393b54b30f66dcb18c243a07cbec628..d25fef0f66e21a58400d5a6a23cb36a042a3c0f7 100644 (file)
@@ -386,11 +386,11 @@ static int kvm_swap_s1_desc(struct kvm_vcpu *vcpu, u64 pa, u64 old, u64 new,
                            struct s1_walk_info *wi)
 {
        if (wi->be) {
-               old = cpu_to_be64(old);
-               new = cpu_to_be64(new);
+               old = (__force u64)cpu_to_be64(old);
+               new = (__force u64)cpu_to_be64(new);
        } else {
-               old = cpu_to_le64(old);
-               new = cpu_to_le64(new);
+               old = (__force u64)cpu_to_le64(old);
+               new = (__force u64)cpu_to_le64(new);
        }
 
        return __kvm_at_swap_desc(vcpu->kvm, pa, old, new);
index 88d7dfb44410c6227d41836be08e80794d7e2c3a..911fc99ed99d9062e483f97a79c646659b798629 100644 (file)
@@ -224,11 +224,11 @@ static int swap_guest_s2_desc(struct kvm_vcpu *vcpu, phys_addr_t pa, u64 old, u6
                              struct s2_walk_info *wi)
 {
        if (wi->be) {
-               old = cpu_to_be64(old);
-               new = cpu_to_be64(new);
+               old = (__force u64)cpu_to_be64(old);
+               new = (__force u64)cpu_to_be64(new);
        } else {
-               old = cpu_to_le64(old);
-               new = cpu_to_le64(new);
+               old = (__force u64)cpu_to_le64(old);
+               new = (__force u64)cpu_to_le64(new);
        }
 
        return __kvm_at_swap_desc(vcpu->kvm, pa, old, new);