fs/pstore/ram_core.c:278:34: sparse: sparse: incorrect type in argument 1 (different address spaces)

From: kernel test robot

Date: Sun May 24 2026 - 22:53:55 EST


Hi Tiwei,

First bad commit (maybe != root cause):

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: e7ae89a0c97ce2b68b0983cd01eda67cf373517d
commit: a0e2cb6a90634f3dc80f16e882a683ee5761b0b0 um: Add VFIO-based virtual PCI driver
date: 1 year, 1 month ago
config: um-randconfig-r123-20260525 (https://download.01.org/0day-ci/archive/20260525/202605251003.InuuGWYe-lkp@xxxxxxxxx/config)
compiler: gcc-13 (Debian 13.3.0-16) 13.3.0
sparse: v0.6.5-rc1
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260525/202605251003.InuuGWYe-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
| Fixes: a0e2cb6a9063 ("um: Add VFIO-based virtual PCI driver")
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605251003.InuuGWYe-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> fs/pstore/ram_core.c:278:34: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void volatile [noderef] __iomem *addr @@ got unsigned char * @@
fs/pstore/ram_core.c:278:34: sparse: expected void volatile [noderef] __iomem *addr
fs/pstore/ram_core.c:278:34: sparse: got unsigned char *
>> fs/pstore/ram_core.c:311:50: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got unsigned char * @@
fs/pstore/ram_core.c:311:50: sparse: expected void const volatile [noderef] __iomem *addr
fs/pstore/ram_core.c:311:50: sparse: got unsigned char *
fs/pstore/ram_core.c:312:65: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const volatile [noderef] __iomem *addr @@ got unsigned char * @@
fs/pstore/ram_core.c:312:65: sparse: expected void const volatile [noderef] __iomem *addr
fs/pstore/ram_core.c:312:65: sparse: got unsigned char *
fs/pstore/ram_core.c:470:20: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void *va @@ got void [noderef] __iomem * @@
fs/pstore/ram_core.c:470:20: sparse: expected void *va
fs/pstore/ram_core.c:470:20: sparse: got void [noderef] __iomem *
fs/pstore/ram_core.c:472:20: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void *va @@ got void [noderef] __iomem * @@
fs/pstore/ram_core.c:472:20: sparse: expected void *va
fs/pstore/ram_core.c:472:20: sparse: got void [noderef] __iomem *
fs/pstore/ram_core.c:566:36: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void volatile [noderef] __iomem *addr @@ got void *vaddr @@
fs/pstore/ram_core.c:566:36: sparse: expected void volatile [noderef] __iomem *addr
fs/pstore/ram_core.c:566:36: sparse: got void *vaddr
fs/pstore/ram_core.c:69:17: sparse: sparse: context imbalance in 'buffer_start_add' - unexpected unlock
fs/pstore/ram_core.c:95:17: sparse: sparse: context imbalance in 'buffer_size_add' - unexpected unlock

vim +278 fs/pstore/ram_core.c

9cc05ad97c5728 drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 273
a15d0b365e9bbf drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 274 static void notrace persistent_ram_update(struct persistent_ram_zone *prz,
808d0387eb7df3 drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 275 const void *s, unsigned int start, unsigned int count)
9cc05ad97c5728 drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 276 {
9cc05ad97c5728 drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 277 struct persistent_ram_buffer *buffer = prz->buffer;
7e75678d23167c fs/pstore/ram_core.c Furquan Shaikh 2016-02-15 @278 memcpy_toio(buffer->data + start, s, count);
808d0387eb7df3 drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 279 persistent_ram_update_ecc(prz, start, count);
9cc05ad97c5728 drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 280 }
9cc05ad97c5728 drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 281
5bf6d1b92715f2 fs/pstore/ram_core.c Mark Salyzyn 2016-09-01 282 static int notrace persistent_ram_update_user(struct persistent_ram_zone *prz,
5bf6d1b92715f2 fs/pstore/ram_core.c Mark Salyzyn 2016-09-01 283 const void __user *s, unsigned int start, unsigned int count)
5bf6d1b92715f2 fs/pstore/ram_core.c Mark Salyzyn 2016-09-01 284 {
5bf6d1b92715f2 fs/pstore/ram_core.c Mark Salyzyn 2016-09-01 285 struct persistent_ram_buffer *buffer = prz->buffer;
ff847781049c37 fs/pstore/ram_core.c Al Viro 2020-02-18 286 int ret = unlikely(copy_from_user(buffer->data + start, s, count)) ?
5bf6d1b92715f2 fs/pstore/ram_core.c Mark Salyzyn 2016-09-01 287 -EFAULT : 0;
5bf6d1b92715f2 fs/pstore/ram_core.c Mark Salyzyn 2016-09-01 288 persistent_ram_update_ecc(prz, start, count);
5bf6d1b92715f2 fs/pstore/ram_core.c Mark Salyzyn 2016-09-01 289 return ret;
5bf6d1b92715f2 fs/pstore/ram_core.c Mark Salyzyn 2016-09-01 290 }
5bf6d1b92715f2 fs/pstore/ram_core.c Mark Salyzyn 2016-09-01 291
201e4aca5aa179 fs/pstore/ram_core.c Anton Vorontsov 2012-05-26 292 void persistent_ram_save_old(struct persistent_ram_zone *prz)
9cc05ad97c5728 drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 293 {
9cc05ad97c5728 drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 294 struct persistent_ram_buffer *buffer = prz->buffer;
808d0387eb7df3 drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 295 size_t size = buffer_size(prz);
808d0387eb7df3 drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 296 size_t start = buffer_start(prz);
9cc05ad97c5728 drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 297
201e4aca5aa179 fs/pstore/ram_core.c Anton Vorontsov 2012-05-26 298 if (!size)
201e4aca5aa179 fs/pstore/ram_core.c Anton Vorontsov 2012-05-26 299 return;
c672528aec4a1c drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 300
201e4aca5aa179 fs/pstore/ram_core.c Anton Vorontsov 2012-05-26 301 if (!prz->old_log) {
201e4aca5aa179 fs/pstore/ram_core.c Anton Vorontsov 2012-05-26 302 persistent_ram_ecc_old(prz);
104fd0b5e94815 fs/pstore/ram_core.c Yuxiao Zhang 2023-06-27 303 prz->old_log = kvzalloc(size, GFP_KERNEL);
201e4aca5aa179 fs/pstore/ram_core.c Anton Vorontsov 2012-05-26 304 }
201e4aca5aa179 fs/pstore/ram_core.c Anton Vorontsov 2012-05-26 305 if (!prz->old_log) {
ef74885353e0ee fs/pstore/ram_core.c Fabian Frederick 2014-06-06 306 pr_err("failed to allocate buffer\n");
c672528aec4a1c drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 307 return;
c672528aec4a1c drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 308 }
c672528aec4a1c drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 309
808d0387eb7df3 drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 310 prz->old_log_size = size;
d771fdf94180de fs/pstore/ram_core.c Andrew Bresticker 2016-02-15 @311 memcpy_fromio(prz->old_log, &buffer->data[start], size - start);
d771fdf94180de fs/pstore/ram_core.c Andrew Bresticker 2016-02-15 312 memcpy_fromio(prz->old_log + size - start, &buffer->data[0], start);
c672528aec4a1c drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 313 }
c672528aec4a1c drivers/staging/android/persistent_ram.c Colin Cross 2012-03-07 314

:::::: The code at line 278 was first introduced by commit
:::::: 7e75678d23167c2527e655658a8ef36a36c8b4d9 pstore/ram: Use memcpy_toio instead of memcpy

:::::: TO: Furquan Shaikh <furquan@xxxxxxxxxx>
:::::: CC: Kees Cook <keescook@xxxxxxxxxxxx>

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