arch/arc/kernel/smp.c:277:30: sparse: sparse: dereference of noderef expression

From: kernel test robot
Date: Sat Jun 04 2022 - 04:39:36 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 032dcf09e2bf7c822be25b4abef7a6c913870d98
commit: c6ed4d84a2c49de7d6f490144cca7b4a4831fb6e ARC: remove redundant READ_ONCE() in cmpxchg loop
date: 7 weeks ago
config: arc-randconfig-s032-20220603 (https://download.01.org/0day-ci/archive/20220604/202206041630.8CNeV2bc-lkp@xxxxxxxxx/config)
compiler: arc-elf-gcc (GCC) 11.3.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-18-g56afb504-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c6ed4d84a2c49de7d6f490144cca7b4a4831fb6e
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout c6ed4d84a2c49de7d6f490144cca7b4a4831fb6e
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arc SHELL=/bin/bash arch/arc/kernel/

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


sparse warnings: (new ones prefixed by >>)
arch/arc/kernel/smp.c:264:48: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned long [noderef] __percpu *ipi_data_ptr @@ got unsigned long * @@
arch/arc/kernel/smp.c:264:48: sparse: expected unsigned long [noderef] __percpu *ipi_data_ptr
arch/arc/kernel/smp.c:264:48: sparse: got unsigned long *
arch/arc/kernel/smp.c:279:18: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile *v @@ got unsigned long [noderef] __percpu *__ai_ptr @@
arch/arc/kernel/smp.c:279:18: sparse: expected void const volatile *v
arch/arc/kernel/smp.c:279:18: sparse: got unsigned long [noderef] __percpu *__ai_ptr
arch/arc/kernel/smp.c:413:72: sparse: sparse: incorrect type in argument 4 (different address spaces) @@ expected void [noderef] __percpu *percpu_dev_id @@ got int *dev @@
arch/arc/kernel/smp.c:413:72: sparse: expected void [noderef] __percpu *percpu_dev_id
arch/arc/kernel/smp.c:413:72: sparse: got int *dev
>> arch/arc/kernel/smp.c:277:30: sparse: sparse: dereference of noderef expression

vim +277 arch/arc/kernel/smp.c

261
262 static void ipi_send_msg_one(int cpu, enum ipi_msg_type msg)
263 {
264 unsigned long __percpu *ipi_data_ptr = per_cpu_ptr(&ipi_data, cpu);
265 unsigned long old, new;
266 unsigned long flags;
267
268 pr_debug("%d Sending msg [%d] to %d\n", smp_processor_id(), msg, cpu);
269
270 local_irq_save(flags);
271
272 /*
273 * Atomically write new msg bit (in case others are writing too),
274 * and read back old value
275 */
276 do {
> 277 new = old = *ipi_data_ptr;
278 new |= 1U << msg;
279 } while (cmpxchg(ipi_data_ptr, old, new) != old);
280
281 /*
282 * Call the platform specific IPI kick function, but avoid if possible:
283 * Only do so if there's no pending msg from other concurrent sender(s).
284 * Otherwise, receiver will see this msg as well when it takes the
285 * IPI corresponding to that msg. This is true, even if it is already in
286 * IPI handler, because !@old means it has not yet dequeued the msg(s)
287 * so @new msg can be a free-loader
288 */
289 if (plat_smp_ops.ipi_send && !old)
290 plat_smp_ops.ipi_send(cpu);
291
292 local_irq_restore(flags);
293 }
294

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