drivers/edac/thunderx_edac.c:438:25: sparse: sparse: incorrect type in argument 1 (different address spaces)

From: kernel test robot
Date: Sun Aug 07 2022 - 09:09:30 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 1612c382ffbdf1f673caec76502b1c00e6d35363
commit: f68f2ff91512c199ec24883001245912afc17873 fortify: Detect struct member overflows in memcpy() at compile-time
date: 6 months ago
config: arm64-randconfig-s052-20220804 (https://download.01.org/0day-ci/archive/20220807/202208072036.aILldUBV-lkp@xxxxxxxxx/config)
compiler: aarch64-linux-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=f68f2ff91512c199ec24883001245912afc17873
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout f68f2ff91512c199ec24883001245912afc17873
# 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=arm64 SHELL=/bin/bash drivers/edac/

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

sparse warnings: (new ones prefixed by >>)
drivers/edac/thunderx_edac.c:428:14: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void [noderef] __iomem *addr @@ got void * @@
drivers/edac/thunderx_edac.c:428:14: sparse: expected void [noderef] __iomem *addr
drivers/edac/thunderx_edac.c:428:14: sparse: got void *
>> drivers/edac/thunderx_edac.c:438:25: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem * @@
drivers/edac/thunderx_edac.c:438:25: sparse: expected void const *
drivers/edac/thunderx_edac.c:438:25: sparse: got void [noderef] __iomem *
>> drivers/edac/thunderx_edac.c:438:25: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem * @@
drivers/edac/thunderx_edac.c:438:25: sparse: expected void const *
drivers/edac/thunderx_edac.c:438:25: sparse: got void [noderef] __iomem *
drivers/edac/thunderx_edac.c:438:25: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem * @@
drivers/edac/thunderx_edac.c:438:25: sparse: expected void const *
drivers/edac/thunderx_edac.c:438:25: sparse: got void [noderef] __iomem *
drivers/edac/thunderx_edac.c:760:20: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void *l2c_ioaddr @@ got void [noderef] __iomem * @@
drivers/edac/thunderx_edac.c:760:20: sparse: expected void *l2c_ioaddr
drivers/edac/thunderx_edac.c:760:20: sparse: got void [noderef] __iomem *
drivers/edac/thunderx_edac.c:767:28: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got void *l2c_ioaddr @@
drivers/edac/thunderx_edac.c:767:28: sparse: expected void const volatile [noderef] __iomem *addr
drivers/edac/thunderx_edac.c:767:28: sparse: got void *l2c_ioaddr
drivers/edac/thunderx_edac.c:767:28: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got void *l2c_ioaddr @@
drivers/edac/thunderx_edac.c:767:28: sparse: expected void const volatile [noderef] __iomem *addr
drivers/edac/thunderx_edac.c:767:28: sparse: got void *l2c_ioaddr
drivers/edac/thunderx_edac.c:767:28: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got void *l2c_ioaddr @@
drivers/edac/thunderx_edac.c:767:28: sparse: expected void const volatile [noderef] __iomem *addr
drivers/edac/thunderx_edac.c:767:28: sparse: got void *l2c_ioaddr
drivers/edac/thunderx_edac.c:767:28: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got void *l2c_ioaddr @@
drivers/edac/thunderx_edac.c:767:28: sparse: expected void const volatile [noderef] __iomem *addr
drivers/edac/thunderx_edac.c:767:28: sparse: got void *l2c_ioaddr
drivers/edac/thunderx_edac.c:767:28: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got void *l2c_ioaddr @@
drivers/edac/thunderx_edac.c:767:28: sparse: expected void const volatile [noderef] __iomem *addr
drivers/edac/thunderx_edac.c:767:28: sparse: got void *l2c_ioaddr
drivers/edac/thunderx_edac.c:767:28: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got void *l2c_ioaddr @@
drivers/edac/thunderx_edac.c:767:28: sparse: expected void const volatile [noderef] __iomem *addr
drivers/edac/thunderx_edac.c:767:28: sparse: got void *l2c_ioaddr
drivers/edac/thunderx_edac.c:767:28: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got void *l2c_ioaddr @@
drivers/edac/thunderx_edac.c:767:28: sparse: expected void const volatile [noderef] __iomem *addr
drivers/edac/thunderx_edac.c:767:28: sparse: got void *l2c_ioaddr
drivers/edac/thunderx_edac.c:767:28: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got void *l2c_ioaddr @@
drivers/edac/thunderx_edac.c:767:28: sparse: expected void const volatile [noderef] __iomem *addr
drivers/edac/thunderx_edac.c:767:28: sparse: got void *l2c_ioaddr
drivers/edac/thunderx_edac.c:767:28: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got void *l2c_ioaddr @@
drivers/edac/thunderx_edac.c:767:28: sparse: expected void const volatile [noderef] __iomem *addr
drivers/edac/thunderx_edac.c:767:28: sparse: got void *l2c_ioaddr
drivers/edac/thunderx_edac.c:767:28: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got void *l2c_ioaddr @@
drivers/edac/thunderx_edac.c:767:28: sparse: expected void const volatile [noderef] __iomem *addr
drivers/edac/thunderx_edac.c:767:28: sparse: got void *l2c_ioaddr
drivers/edac/thunderx_edac.c:769:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void volatile [noderef] __iomem *addr @@ got void *l2c_ioaddr @@
drivers/edac/thunderx_edac.c:769:17: sparse: expected void volatile [noderef] __iomem *addr
drivers/edac/thunderx_edac.c:769:17: sparse: got void *l2c_ioaddr

vim +438 drivers/edac/thunderx_edac.c

41003396f932d7f Sergey Temerkhanov 2017-03-24 405
41003396f932d7f Sergey Temerkhanov 2017-03-24 406 static ssize_t thunderx_lmc_inject_ecc_write(struct file *file,
41003396f932d7f Sergey Temerkhanov 2017-03-24 407 const char __user *data,
41003396f932d7f Sergey Temerkhanov 2017-03-24 408 size_t count, loff_t *ppos)
41003396f932d7f Sergey Temerkhanov 2017-03-24 409 {
41003396f932d7f Sergey Temerkhanov 2017-03-24 410 struct thunderx_lmc *lmc = file->private_data;
41003396f932d7f Sergey Temerkhanov 2017-03-24 411 unsigned int cline_size = cache_line_size();
6663484b4e2d98f Kees Cook 2018-06-29 412 u8 *tmp;
41003396f932d7f Sergey Temerkhanov 2017-03-24 413 void __iomem *addr;
41003396f932d7f Sergey Temerkhanov 2017-03-24 414 unsigned int offs, timeout = 100000;
41003396f932d7f Sergey Temerkhanov 2017-03-24 415
41003396f932d7f Sergey Temerkhanov 2017-03-24 416 atomic_set(&lmc->ecc_int, 0);
41003396f932d7f Sergey Temerkhanov 2017-03-24 417
41003396f932d7f Sergey Temerkhanov 2017-03-24 418 lmc->mem = alloc_pages_node(lmc->node, GFP_KERNEL, 0);
41003396f932d7f Sergey Temerkhanov 2017-03-24 419 if (!lmc->mem)
41003396f932d7f Sergey Temerkhanov 2017-03-24 420 return -ENOMEM;
41003396f932d7f Sergey Temerkhanov 2017-03-24 421
6663484b4e2d98f Kees Cook 2018-06-29 422 tmp = kmalloc(cline_size, GFP_KERNEL);
6663484b4e2d98f Kees Cook 2018-06-29 423 if (!tmp) {
6663484b4e2d98f Kees Cook 2018-06-29 424 __free_pages(lmc->mem, 0);
6663484b4e2d98f Kees Cook 2018-06-29 425 return -ENOMEM;
6663484b4e2d98f Kees Cook 2018-06-29 426 }
6663484b4e2d98f Kees Cook 2018-06-29 427
41003396f932d7f Sergey Temerkhanov 2017-03-24 428 addr = page_address(lmc->mem);
41003396f932d7f Sergey Temerkhanov 2017-03-24 429
41003396f932d7f Sergey Temerkhanov 2017-03-24 430 while (!atomic_read(&lmc->ecc_int) && timeout--) {
41003396f932d7f Sergey Temerkhanov 2017-03-24 431 stop_machine(inject_ecc_fn, lmc, NULL);
41003396f932d7f Sergey Temerkhanov 2017-03-24 432
6663484b4e2d98f Kees Cook 2018-06-29 433 for (offs = 0; offs < PAGE_SIZE; offs += cline_size) {
41003396f932d7f Sergey Temerkhanov 2017-03-24 434 /*
41003396f932d7f Sergey Temerkhanov 2017-03-24 435 * Do a load from the previously rigged location
41003396f932d7f Sergey Temerkhanov 2017-03-24 436 * This should generate an error interrupt.
41003396f932d7f Sergey Temerkhanov 2017-03-24 437 */
41003396f932d7f Sergey Temerkhanov 2017-03-24 @438 memcpy(tmp, addr + offs, cline_size);
41003396f932d7f Sergey Temerkhanov 2017-03-24 439 asm volatile("dsb ld\n");
41003396f932d7f Sergey Temerkhanov 2017-03-24 440 }
41003396f932d7f Sergey Temerkhanov 2017-03-24 441 }
41003396f932d7f Sergey Temerkhanov 2017-03-24 442
6663484b4e2d98f Kees Cook 2018-06-29 443 kfree(tmp);
41003396f932d7f Sergey Temerkhanov 2017-03-24 444 __free_pages(lmc->mem, 0);
41003396f932d7f Sergey Temerkhanov 2017-03-24 445
41003396f932d7f Sergey Temerkhanov 2017-03-24 446 return count;
41003396f932d7f Sergey Temerkhanov 2017-03-24 447 }
41003396f932d7f Sergey Temerkhanov 2017-03-24 448

:::::: The code at line 438 was first introduced by commit
:::::: 41003396f932d7f027725c7acebb6a7caa41dc3e EDAC, thunderx: Add Cavium ThunderX EDAC driver

:::::: TO: Sergey Temerkhanov <s.temerkhanov@xxxxxxxxx>
:::::: CC: Borislav Petkov <bp@xxxxxxx>

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