arch/powerpc/include/asm/cmpxchg.h:626:47: sparse: sparse: cast truncates bits from constant value (5deadbeef000eb9f becomes f000eb9f)

From: kernel test robot
Date: Tue Nov 07 2023 - 11:32:09 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: be3ca57cfb777ad820c6659d52e60bbdd36bf5ff
commit: c3c510ce431cd99fa10dcd50d995c8e89330ee5b bpf: Add 'owner' field to bpf_{list,rb}_node
date: 4 months ago
config: powerpc64-randconfig-r113-20231107 (https://download.01.org/0day-ci/archive/20231107/202311072357.a2ejf6Jb-lkp@xxxxxxxxx/config)
compiler: powerpc64-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231107/202311072357.a2ejf6Jb-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311072357.a2ejf6Jb-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
kernel/bpf/helpers.c: note: in included file (through arch/powerpc/include/asm/pgtable-be-types.h, arch/powerpc/include/asm/page.h, arch/powerpc/include/asm/mmu.h, ...):
>> arch/powerpc/include/asm/cmpxchg.h:626:47: sparse: sparse: cast truncates bits from constant value (5deadbeef000eb9f becomes f000eb9f)
arch/powerpc/include/asm/cmpxchg.h:628:48: sparse: sparse: cast truncates bits from constant value (5deadbeef000eb9f becomes f000eb9f)
>> arch/powerpc/include/asm/cmpxchg.h:626:47: sparse: sparse: cast truncates bits from constant value (5deadbeef000eb9f becomes f000eb9f)
arch/powerpc/include/asm/cmpxchg.h:628:48: sparse: sparse: cast truncates bits from constant value (5deadbeef000eb9f becomes f000eb9f)
kernel/bpf/helpers.c:2419:18: sparse: sparse: context imbalance in 'bpf_rcu_read_lock' - wrong count at exit
kernel/bpf/helpers.c:2424:18: sparse: sparse: context imbalance in 'bpf_rcu_read_unlock' - unexpected unlock

vim +626 arch/powerpc/include/asm/cmpxchg.h

ae3a197e3d0bfe3 David Howells 2012-03-28 619
ae3a197e3d0bfe3 David Howells 2012-03-28 620 static __always_inline unsigned long
da58b23cb976ab8 Michael Ellerman 2016-11-24 621 __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new,
ae3a197e3d0bfe3 David Howells 2012-03-28 622 unsigned int size)
ae3a197e3d0bfe3 David Howells 2012-03-28 623 {
ae3a197e3d0bfe3 David Howells 2012-03-28 624 switch (size) {
d0563a1297e234e Pan Xinhui 2016-04-27 625 case 1:
d0563a1297e234e Pan Xinhui 2016-04-27 @626 return __cmpxchg_u8(ptr, old, new);
d0563a1297e234e Pan Xinhui 2016-04-27 627 case 2:
d0563a1297e234e Pan Xinhui 2016-04-27 628 return __cmpxchg_u16(ptr, old, new);
ae3a197e3d0bfe3 David Howells 2012-03-28 629 case 4:
ae3a197e3d0bfe3 David Howells 2012-03-28 630 return __cmpxchg_u32(ptr, old, new);
ae3a197e3d0bfe3 David Howells 2012-03-28 631 #ifdef CONFIG_PPC64
ae3a197e3d0bfe3 David Howells 2012-03-28 632 case 8:
ae3a197e3d0bfe3 David Howells 2012-03-28 633 return __cmpxchg_u64(ptr, old, new);
ae3a197e3d0bfe3 David Howells 2012-03-28 634 #endif
ae3a197e3d0bfe3 David Howells 2012-03-28 635 }
10d8b1480e6966b pan xinhui 2016-02-23 636 BUILD_BUG_ON_MSG(1, "Unsupported size for __cmpxchg");
ae3a197e3d0bfe3 David Howells 2012-03-28 637 return old;
ae3a197e3d0bfe3 David Howells 2012-03-28 638 }
ae3a197e3d0bfe3 David Howells 2012-03-28 639

:::::: The code at line 626 was first introduced by commit
:::::: d0563a1297e234ed37f6b51c2e9321accebd1839 powerpc: Implement {cmp}xchg for u8 and u16

:::::: TO: Pan Xinhui <xinhui.pan@xxxxxxxxxxxxxxxxxx>
:::::: CC: Michael Ellerman <mpe@xxxxxxxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki