arch/powerpc/platforms/52xx/mpc52xx_pm.c:133:9: sparse: sparse: incorrect type in argument 1 (different address spaces)

From: kernel test robot
Date: Mon Aug 08 2022 - 17:56:42 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: c8a684e2e110376c58f0bfa30fb3855d1e319670
commit: f68f2ff91512c199ec24883001245912afc17873 fortify: Detect struct member overflows in memcpy() at compile-time
date: 6 months ago
config: powerpc-randconfig-s031-20220808 (https://download.01.org/0day-ci/archive/20220809/202208090505.55iG35ny-lkp@xxxxxxxxx/config)
compiler: powerpc-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=powerpc SHELL=/bin/bash arch/powerpc/platforms/52xx/

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/powerpc/platforms/52xx/mpc52xx_pm.c:133:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem *static [assigned] [toplevel] sram @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:133:9: sparse: expected void const *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:133:9: sparse: got void [noderef] __iomem *static [assigned] [toplevel] sram
>> arch/powerpc/platforms/52xx/mpc52xx_pm.c:133:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem *static [assigned] [toplevel] sram @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:133:9: sparse: expected void const *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:133:9: sparse: got void [noderef] __iomem *static [assigned] [toplevel] sram
arch/powerpc/platforms/52xx/mpc52xx_pm.c:133:9: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem *static [assigned] [toplevel] sram @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:133:9: sparse: expected void const *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:133:9: sparse: got void [noderef] __iomem *static [assigned] [toplevel] sram
arch/powerpc/platforms/52xx/mpc52xx_pm.c:136:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem *static [assigned] [toplevel] sram @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:136:9: sparse: expected void const *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:136:9: sparse: got void [noderef] __iomem *static [assigned] [toplevel] sram
arch/powerpc/platforms/52xx/mpc52xx_pm.c:136:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem *static [assigned] [toplevel] sram @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:136:9: sparse: expected void const *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:136:9: sparse: got void [noderef] __iomem *static [assigned] [toplevel] sram
>> arch/powerpc/platforms/52xx/mpc52xx_pm.c:136:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void * @@ got void [noderef] __iomem *static [assigned] [toplevel] sram @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:136:9: sparse: expected void *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:136:9: sparse: got void [noderef] __iomem *static [assigned] [toplevel] sram
>> arch/powerpc/platforms/52xx/mpc52xx_pm.c:155:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem *irq_0x500 @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:155:9: sparse: expected void const *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:155:9: sparse: got void [noderef] __iomem *irq_0x500
>> arch/powerpc/platforms/52xx/mpc52xx_pm.c:155:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem *irq_0x500 @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:155:9: sparse: expected void const *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:155:9: sparse: got void [noderef] __iomem *irq_0x500
arch/powerpc/platforms/52xx/mpc52xx_pm.c:155:9: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem *irq_0x500 @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:155:9: sparse: expected void const *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:155:9: sparse: got void [noderef] __iomem *irq_0x500
arch/powerpc/platforms/52xx/mpc52xx_pm.c:156:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem *irq_0x500 @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:156:9: sparse: expected void const *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:156:9: sparse: got void [noderef] __iomem *irq_0x500
arch/powerpc/platforms/52xx/mpc52xx_pm.c:156:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem *irq_0x500 @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:156:9: sparse: expected void const *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:156:9: sparse: got void [noderef] __iomem *irq_0x500
>> arch/powerpc/platforms/52xx/mpc52xx_pm.c:156:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void * @@ got void [noderef] __iomem *irq_0x500 @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:156:9: sparse: expected void *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:156:9: sparse: got void [noderef] __iomem *irq_0x500
arch/powerpc/platforms/52xx/mpc52xx_pm.c:163:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem *irq_0x500 @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:163:9: sparse: expected void const *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:163:9: sparse: got void [noderef] __iomem *irq_0x500
arch/powerpc/platforms/52xx/mpc52xx_pm.c:163:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem *irq_0x500 @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:163:9: sparse: expected void const *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:163:9: sparse: got void [noderef] __iomem *irq_0x500
arch/powerpc/platforms/52xx/mpc52xx_pm.c:163:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void * @@ got void [noderef] __iomem *irq_0x500 @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:163:9: sparse: expected void *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:163:9: sparse: got void [noderef] __iomem *irq_0x500
arch/powerpc/platforms/52xx/mpc52xx_pm.c:176:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem *static [assigned] [toplevel] sram @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:176:9: sparse: expected void const *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:176:9: sparse: got void [noderef] __iomem *static [assigned] [toplevel] sram
arch/powerpc/platforms/52xx/mpc52xx_pm.c:176:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const * @@ got void [noderef] __iomem *static [assigned] [toplevel] sram @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:176:9: sparse: expected void const *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:176:9: sparse: got void [noderef] __iomem *static [assigned] [toplevel] sram
arch/powerpc/platforms/52xx/mpc52xx_pm.c:176:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void * @@ got void [noderef] __iomem *static [assigned] [toplevel] sram @@
arch/powerpc/platforms/52xx/mpc52xx_pm.c:176:9: sparse: expected void *
arch/powerpc/platforms/52xx/mpc52xx_pm.c:176:9: sparse: got void [noderef] __iomem *static [assigned] [toplevel] sram

vim +133 arch/powerpc/platforms/52xx/mpc52xx_pm.c

2e1ee1f76684c5 Domen Puncer 2007-05-07 112
2e1ee1f76684c5 Domen Puncer 2007-05-07 113 int mpc52xx_pm_enter(suspend_state_t state)
2e1ee1f76684c5 Domen Puncer 2007-05-07 114 {
2e1ee1f76684c5 Domen Puncer 2007-05-07 115 u32 clk_enables;
2e1ee1f76684c5 Domen Puncer 2007-05-07 116 u32 msr, hid0;
2e1ee1f76684c5 Domen Puncer 2007-05-07 117 u32 intr_main_mask;
d3e0e02804a5f4 Domen Puncer 2007-07-09 118 void __iomem * irq_0x500 = (void __iomem *)CONFIG_KERNEL_START + 0x500;
2e1ee1f76684c5 Domen Puncer 2007-05-07 119 unsigned long irq_0x500_stop = (unsigned long)irq_0x500 + mpc52xx_ds_cached_size;
741c5640a15a23 Kees Cook 2018-07-02 120 char saved_0x500[0x600-0x500];
741c5640a15a23 Kees Cook 2018-07-02 121
741c5640a15a23 Kees Cook 2018-07-02 122 if (WARN_ON(mpc52xx_ds_cached_size > sizeof(saved_0x500)))
741c5640a15a23 Kees Cook 2018-07-02 123 return -ENOMEM;
2e1ee1f76684c5 Domen Puncer 2007-05-07 124
2e1ee1f76684c5 Domen Puncer 2007-05-07 125 /* disable all interrupts in PIC */
2e1ee1f76684c5 Domen Puncer 2007-05-07 126 intr_main_mask = in_be32(&intr->main_mask);
2e1ee1f76684c5 Domen Puncer 2007-05-07 127 out_be32(&intr->main_mask, intr_main_mask | 0x1ffff);
2e1ee1f76684c5 Domen Puncer 2007-05-07 128
2e1ee1f76684c5 Domen Puncer 2007-05-07 129 /* don't let DEC expire any time soon */
2e1ee1f76684c5 Domen Puncer 2007-05-07 130 mtspr(SPRN_DEC, 0x7fffffff);
2e1ee1f76684c5 Domen Puncer 2007-05-07 131
2e1ee1f76684c5 Domen Puncer 2007-05-07 132 /* save SRAM */
2e1ee1f76684c5 Domen Puncer 2007-05-07 @133 memcpy(saved_sram, sram, sram_size);
2e1ee1f76684c5 Domen Puncer 2007-05-07 134
2e1ee1f76684c5 Domen Puncer 2007-05-07 135 /* copy low level suspend code to sram */
2e1ee1f76684c5 Domen Puncer 2007-05-07 @136 memcpy(sram, mpc52xx_ds_sram, mpc52xx_ds_sram_size);
2e1ee1f76684c5 Domen Puncer 2007-05-07 137
2e1ee1f76684c5 Domen Puncer 2007-05-07 138 out_8(&cdm->ccs_sleep_enable, 1);
2e1ee1f76684c5 Domen Puncer 2007-05-07 139 out_8(&cdm->osc_sleep_enable, 1);
2e1ee1f76684c5 Domen Puncer 2007-05-07 140 out_8(&cdm->ccs_qreq_test, 1);
2e1ee1f76684c5 Domen Puncer 2007-05-07 141
2e1ee1f76684c5 Domen Puncer 2007-05-07 142 /* disable all but SDRAM and bestcomm (SRAM) clocks */
2e1ee1f76684c5 Domen Puncer 2007-05-07 143 clk_enables = in_be32(&cdm->clk_enables);
2e1ee1f76684c5 Domen Puncer 2007-05-07 144 out_be32(&cdm->clk_enables, clk_enables & 0x00088000);
2e1ee1f76684c5 Domen Puncer 2007-05-07 145
2e1ee1f76684c5 Domen Puncer 2007-05-07 146 /* disable power management */
2e1ee1f76684c5 Domen Puncer 2007-05-07 147 msr = mfmsr();
2e1ee1f76684c5 Domen Puncer 2007-05-07 148 mtmsr(msr & ~MSR_POW);
2e1ee1f76684c5 Domen Puncer 2007-05-07 149
2e1ee1f76684c5 Domen Puncer 2007-05-07 150 /* enable sleep mode, disable others */
2e1ee1f76684c5 Domen Puncer 2007-05-07 151 hid0 = mfspr(SPRN_HID0);
2e1ee1f76684c5 Domen Puncer 2007-05-07 152 mtspr(SPRN_HID0, (hid0 & ~(HID0_DOZE | HID0_NAP | HID0_DPM)) | HID0_SLEEP);
2e1ee1f76684c5 Domen Puncer 2007-05-07 153
2e1ee1f76684c5 Domen Puncer 2007-05-07 154 /* save original, copy our irq handler, flush from dcache and invalidate icache */
2e1ee1f76684c5 Domen Puncer 2007-05-07 @155 memcpy(saved_0x500, irq_0x500, mpc52xx_ds_cached_size);
2e1ee1f76684c5 Domen Puncer 2007-05-07 @156 memcpy(irq_0x500, mpc52xx_ds_cached, mpc52xx_ds_cached_size);
2e1ee1f76684c5 Domen Puncer 2007-05-07 157 flush_icache_range((unsigned long)irq_0x500, irq_0x500_stop);
2e1ee1f76684c5 Domen Puncer 2007-05-07 158
2e1ee1f76684c5 Domen Puncer 2007-05-07 159 /* call low-level sleep code */
2e1ee1f76684c5 Domen Puncer 2007-05-07 160 mpc52xx_deep_sleep(sram, sdram, cdm, intr);
2e1ee1f76684c5 Domen Puncer 2007-05-07 161
2e1ee1f76684c5 Domen Puncer 2007-05-07 162 /* restore original irq handler */
2e1ee1f76684c5 Domen Puncer 2007-05-07 163 memcpy(irq_0x500, saved_0x500, mpc52xx_ds_cached_size);
2e1ee1f76684c5 Domen Puncer 2007-05-07 164 flush_icache_range((unsigned long)irq_0x500, irq_0x500_stop);
2e1ee1f76684c5 Domen Puncer 2007-05-07 165
2e1ee1f76684c5 Domen Puncer 2007-05-07 166 /* restore old power mode */
2e1ee1f76684c5 Domen Puncer 2007-05-07 167 mtmsr(msr & ~MSR_POW);
2e1ee1f76684c5 Domen Puncer 2007-05-07 168 mtspr(SPRN_HID0, hid0);
2e1ee1f76684c5 Domen Puncer 2007-05-07 169 mtmsr(msr);
2e1ee1f76684c5 Domen Puncer 2007-05-07 170
2e1ee1f76684c5 Domen Puncer 2007-05-07 171 out_be32(&cdm->clk_enables, clk_enables);
2e1ee1f76684c5 Domen Puncer 2007-05-07 172 out_8(&cdm->ccs_sleep_enable, 0);
2e1ee1f76684c5 Domen Puncer 2007-05-07 173 out_8(&cdm->osc_sleep_enable, 0);
2e1ee1f76684c5 Domen Puncer 2007-05-07 174
2e1ee1f76684c5 Domen Puncer 2007-05-07 175 /* restore SRAM */
2e1ee1f76684c5 Domen Puncer 2007-05-07 176 memcpy(sram, saved_sram, sram_size);
2e1ee1f76684c5 Domen Puncer 2007-05-07 177
2e1ee1f76684c5 Domen Puncer 2007-05-07 178 /* reenable interrupts in PIC */
2e1ee1f76684c5 Domen Puncer 2007-05-07 179 out_be32(&intr->main_mask, intr_main_mask);
2e1ee1f76684c5 Domen Puncer 2007-05-07 180
2e1ee1f76684c5 Domen Puncer 2007-05-07 181 return 0;
2e1ee1f76684c5 Domen Puncer 2007-05-07 182 }
2e1ee1f76684c5 Domen Puncer 2007-05-07 183

:::::: The code at line 133 was first introduced by commit
:::::: 2e1ee1f76684c5d4dd8e5a08cbf22d57f88769ed [POWERPC] mpc52xx suspend to deep-sleep

:::::: TO: Domen Puncer <domen.puncer@xxxxxxxxxxx>
:::::: CC: Paul Mackerras <paulus@xxxxxxxxx>

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