Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: arm64: Add endian casting to kvm_swap_s[12]_desc()

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>

authored by

Marc Zyngier and committed by
Oliver Upton
b0fc8329 36fe022f

+8 -8
+4 -4
arch/arm64/kvm/at.c
··· 386 386 struct s1_walk_info *wi) 387 387 { 388 388 if (wi->be) { 389 - old = cpu_to_be64(old); 390 - new = cpu_to_be64(new); 389 + old = (__force u64)cpu_to_be64(old); 390 + new = (__force u64)cpu_to_be64(new); 391 391 } else { 392 - old = cpu_to_le64(old); 393 - new = cpu_to_le64(new); 392 + old = (__force u64)cpu_to_le64(old); 393 + new = (__force u64)cpu_to_le64(new); 394 394 } 395 395 396 396 return __kvm_at_swap_desc(vcpu->kvm, pa, old, new);
+4 -4
arch/arm64/kvm/nested.c
··· 224 224 struct s2_walk_info *wi) 225 225 { 226 226 if (wi->be) { 227 - old = cpu_to_be64(old); 228 - new = cpu_to_be64(new); 227 + old = (__force u64)cpu_to_be64(old); 228 + new = (__force u64)cpu_to_be64(new); 229 229 } else { 230 - old = cpu_to_le64(old); 231 - new = cpu_to_le64(new); 230 + old = (__force u64)cpu_to_le64(old); 231 + new = (__force u64)cpu_to_le64(new); 232 232 } 233 233 234 234 return __kvm_at_swap_desc(vcpu->kvm, pa, old, new);