kernel/resource.c:1795:23: sparse: sparse: cast truncates bits from constant value (fffffffff becomes ffffffff)

From: kernel test robot
Date: Tue Sep 20 2022 - 00:50:16 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 521a547ced6477c54b4b0cc206000406c221b4d6
commit: 23a22cd1c98be518774fe7f7e8a5203af050525a cxl/region: Allocate HPA capacity to regions
date: 8 weeks ago
config: arm-randconfig-s042-20220919 (https://download.01.org/0day-ci/archive/20220920/202209201253.FRw5oo2x-lkp@xxxxxxxxx/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=23a22cd1c98be518774fe7f7e8a5203af050525a
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 23a22cd1c98be518774fe7f7e8a5203af050525a
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arm SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>

sparse warnings: (new ones prefixed by >>)
>> kernel/resource.c:1795:23: sparse: sparse: cast truncates bits from constant value (fffffffff becomes ffffffff)
kernel/resource.c:1813:24: sparse: sparse: cast truncates bits from constant value (fffffffff becomes ffffffff)

vim +1795 kernel/resource.c

14b80582c43e4f Dan Williams 2022-05-20 1788
14b80582c43e4f Dan Williams 2022-05-20 1789 static resource_size_t gfr_start(struct resource *base, resource_size_t size,
14b80582c43e4f Dan Williams 2022-05-20 1790 resource_size_t align, unsigned long flags)
14b80582c43e4f Dan Williams 2022-05-20 1791 {
14b80582c43e4f Dan Williams 2022-05-20 1792 if (flags & GFR_DESCENDING) {
14b80582c43e4f Dan Williams 2022-05-20 1793 resource_size_t end;
14b80582c43e4f Dan Williams 2022-05-20 1794
14b80582c43e4f Dan Williams 2022-05-20 @1795 end = min_t(resource_size_t, base->end,
14b80582c43e4f Dan Williams 2022-05-20 1796 (1ULL << MAX_PHYSMEM_BITS) - 1);
14b80582c43e4f Dan Williams 2022-05-20 1797 return end - size + 1;
14b80582c43e4f Dan Williams 2022-05-20 1798 }
14b80582c43e4f Dan Williams 2022-05-20 1799
14b80582c43e4f Dan Williams 2022-05-20 1800 return ALIGN(base->start, align);
14b80582c43e4f Dan Williams 2022-05-20 1801 }
14b80582c43e4f Dan Williams 2022-05-20 1802

:::::: The code at line 1795 was first introduced by commit
:::::: 14b80582c43e4f550acfd93c2b2cadbe36ea0874 resource: Introduce alloc_free_mem_region()

:::::: TO: Dan Williams <dan.j.williams@xxxxxxxxx>
:::::: CC: Dan Williams <dan.j.williams@xxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://01.org/lkp