arch/mips/loongson64/reset.c:85:43: sparse: sparse: cast removes address space '__user' of expression

From: kernel test robot
Date: Thu May 27 2021 - 05:05:24 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: d7c5303fbc8ac874ae3e597a5a0d3707dc0230b4
commit: 6ce48897ce476bed86fde28752c27596e8753277 MIPS: Loongson64: Add kexec/kdump support
date: 6 weeks ago
config: mips-randconfig-s032-20210527 (attached as .config)
compiler: mips64el-linux-gcc (GCC) 9.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.3-341-g8af24329-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6ce48897ce476bed86fde28752c27596e8753277
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 6ce48897ce476bed86fde28752c27596e8753277
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=mips

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


sparse warnings: (new ones prefixed by >>)
command-line: note: in included file:
builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_ACQUIRE redefined
builtin:0:0: sparse: this was the original definition
builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_SEQ_CST redefined
builtin:0:0: sparse: this was the original definition
builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_ACQ_REL redefined
builtin:0:0: sparse: this was the original definition
builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_RELEASE redefined
builtin:0:0: sparse: this was the original definition
>> arch/mips/loongson64/reset.c:85:43: sparse: sparse: cast removes address space '__user' of expression
>> arch/mips/loongson64/reset.c:93:54: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const *__from @@ got void [noderef] __user *buf @@
arch/mips/loongson64/reset.c:93:54: sparse: expected void const *__from
arch/mips/loongson64/reset.c:93:54: sparse: got void [noderef] __user *buf

vim +/__user +85 arch/mips/loongson64/reset.c

69
70 static int loongson_kexec_prepare(struct kimage *image)
71 {
72 int i, argc = 0;
73 unsigned int *argv;
74 char *str, *ptr, *bootloader = "kexec";
75
76 /* argv at offset 0, argv[] at offset KEXEC_ARGV_SIZE/2 */
77 if (image->type == KEXEC_TYPE_DEFAULT)
78 argv = (unsigned int *)kexec_argv;
79 else
80 argv = (unsigned int *)kdump_argv;
81
82 argv[argc++] = (unsigned int)(KEXEC_ARGV_ADDR + KEXEC_ARGV_SIZE/2);
83
84 for (i = 0; i < image->nr_segments; i++) {
> 85 if (!strncmp(bootloader, (char *)image->segment[i].buf,
86 strlen(bootloader))) {
87 /*
88 * convert command line string to array
89 * of parameters (as bootloader does).
90 */
91 int offt;
92 str = (char *)argv + KEXEC_ARGV_SIZE/2;
> 93 memcpy(str, image->segment[i].buf, KEXEC_ARGV_SIZE/2);
94 ptr = strchr(str, ' ');
95
96 while (ptr && (argc < MAX_ARGS)) {
97 *ptr = '\0';
98 if (ptr[1] != ' ') {
99 offt = (int)(ptr - str + 1);
100 argv[argc] = KEXEC_ARGV_ADDR + KEXEC_ARGV_SIZE/2 + offt;
101 argc++;
102 }
103 ptr = strchr(ptr + 1, ' ');
104 }
105 break;
106 }
107 }
108
109 if (image->type == KEXEC_TYPE_DEFAULT)
110 kexec_argc = argc;
111 else
112 kdump_argc = argc;
113
114 /* kexec/kdump need a safe page to save reboot_code_buffer */
115 image->control_code_page = virt_to_page((void *)KEXEC_CTRL_CODE);
116
117 return 0;
118 }
119

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip