On 2022/9/29 23:07, kernel test robot wrote: > tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master > head: de90d455a35e474a184c898e66a6a108c3a99434 > commit: f640b1a57f8e9e513e26aa5b3ee0b905dfebfcf2 [8145/11162] ARM: 9225/1: Make the dumped instructions are consistent with the disassembled ones > config: arm-randconfig-s043-20220925 > 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/next/linux-next.git/commit/?id=f640b1a57f8e9e513e26aa5b3ee0b905dfebfcf2 > git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git > git fetch --no-tags linux-next master > git checkout f640b1a57f8e9e513e26aa5b3ee0b905dfebfcf2 > # 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 >>) > arch/arm/kernel/traps.c:191:39: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got unsigned short [usertype] * @@ > arch/arm/kernel/traps.c:191:39: sparse: expected void const volatile [noderef] __user *ptr > arch/arm/kernel/traps.c:191:39: sparse: got unsigned short [usertype] * > arch/arm/kernel/traps.c:193:39: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got unsigned int [usertype] * @@ > arch/arm/kernel/traps.c:193:39: sparse: expected void const volatile [noderef] __user *ptr > arch/arm/kernel/traps.c:193:39: sparse: got unsigned int [usertype] * These warnings are not caused by this patch. I will use another patch to fix them. if (thumb) - bad = get_user(val, &((u16 *)addr)[i]); + bad = get_user(val, &((u16 __user *)addr)[i]); else - bad = get_user(val, &((u32 *)addr)[i]); + bad = get_user(val, &((u32 __user *)addr)[i]); >>> arch/arm/kernel/traps.c:198:37: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [addressable] [assigned] val @@ got restricted __le16 [usertype] @@ > arch/arm/kernel/traps.c:198:37: sparse: expected unsigned int [addressable] [assigned] val > arch/arm/kernel/traps.c:198:37: sparse: got restricted __le16 [usertype] >>> arch/arm/kernel/traps.c:200:37: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [addressable] [assigned] val @@ got restricted __le32 [usertype] @@ > arch/arm/kernel/traps.c:200:37: sparse: expected unsigned int [addressable] [assigned] val > arch/arm/kernel/traps.c:200:37: sparse: got restricted __le32 [usertype] OK, to clear this static check warning, I need to add "(__force unsigned int)" to perform the forced type conversion, because it requires that the type of 'val' be "__le16" or "__le32". > arch/arm/kernel/traps.c:465:33: sparse: sparse: cast removes address space '__user' of expression > arch/arm/kernel/traps.c:468:41: sparse: sparse: cast removes address space '__user' of expression > arch/arm/kernel/traps.c:473:33: sparse: sparse: cast removes address space '__user' of expression > > vim +198 arch/arm/kernel/traps.c > > 164 > 165 static void dump_instr(const char *lvl, struct pt_regs *regs) > 166 { > 167 unsigned long addr = instruction_pointer(regs); > 168 const int thumb = thumb_mode(regs); > 169 const int width = thumb ? 4 : 8; > 170 char str[sizeof("00000000 ") * 5 + 2 + 1], *p = str; > 171 int i; > 172 > 173 /* > 174 * Note that we now dump the code first, just in case the backtrace > 175 * kills us. > 176 */ > 177 > 178 for (i = -4; i < 1 + !!thumb; i++) { > 179 unsigned int val, bad; > 180 > 181 if (!user_mode(regs)) { > 182 if (thumb) { > 183 u16 val16; > 184 bad = get_kernel_nofault(val16, &((u16 *)addr)[i]); > 185 val = val16; > 186 } else { > 187 bad = get_kernel_nofault(val, &((u32 *)addr)[i]); > 188 } > 189 } else { > 190 if (thumb) > 191 bad = get_user(val, &((u16 *)addr)[i]); > 192 else > 193 bad = get_user(val, &((u32 *)addr)[i]); > 194 } > 195 > 196 if (IS_ENABLED(CONFIG_CPU_ENDIAN_BE8)) { > 197 if (thumb) > > 198 val = cpu_to_le16(val); > 199 else > > 200 val = cpu_to_le32(val); > 201 } > 202 > 203 if (!bad) > 204 p += sprintf(p, i == 0 ? "(%0*x) " : "%0*x ", > 205 width, val); > 206 else { > 207 p += sprintf(p, "bad PC value"); > 208 break; > 209 } > 210 } > 211 printk("%sCode: %s\n", lvl, str); > 212 } > 213 > -- Regards, Zhen Lei