tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 09ce5091ff971cdbfd67ad84dc561ea27f10d67a commit: b7fb4d78a6ade6026d9e5cf438c2a46ab962e032 [12645/14079] RISC-V: use memcpy for kexec_file mode config: riscv-allyesconfig (https://download.01.org/0day-ci/archive/20220525/202205250121.3OgasbW3-lkp@xxxxxxxxx/config) compiler: riscv64-linux-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-14-g5a0004b5-dirty # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=b7fb4d78a6ade6026d9e5cf438c2a46ab962e032 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 b7fb4d78a6ade6026d9e5cf438c2a46ab962e032 # 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=riscv SHELL=/bin/bash arch/riscv/ 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/riscv/kernel/machine_kexec.c:69:25: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const * @@ got void [noderef] __user *buf @@ arch/riscv/kernel/machine_kexec.c:69:25: sparse: expected void const * arch/riscv/kernel/machine_kexec.c:69:25: sparse: got void [noderef] __user *buf arch/riscv/kernel/machine_kexec.c:169:1: sparse: sparse: symbol 'machine_kexec' redeclared with different type (different modifiers): arch/riscv/kernel/machine_kexec.c:169:1: sparse: void extern [addressable] [noreturn] [toplevel] machine_kexec( ... ) arch/riscv/kernel/machine_kexec.c: note: in included file: include/linux/kexec.h:325:13: sparse: note: previously declared as: include/linux/kexec.h:325:13: sparse: void extern [addressable] [toplevel] machine_kexec( ... ) vim +69 arch/riscv/kernel/machine_kexec.c 42 43 /* 44 * machine_kexec_prepare - Initialize kexec 45 * 46 * This function is called from do_kexec_load, when the user has 47 * provided us with an image to be loaded. Its goal is to validate 48 * the image and prepare the control code buffer as needed. 49 * Note that kimage_alloc_init has already been called and the 50 * control buffer has already been allocated. 51 */ 52 int 53 machine_kexec_prepare(struct kimage *image) 54 { 55 struct kimage_arch *internal = &image->arch; 56 struct fdt_header fdt = {0}; 57 void *control_code_buffer = NULL; 58 unsigned int control_code_buffer_sz = 0; 59 int i = 0; 60 61 kexec_image_info(image); 62 63 /* Find the Flattened Device Tree and save its physical address */ 64 for (i = 0; i < image->nr_segments; i++) { 65 if (image->segment[i].memsz <= sizeof(fdt)) 66 continue; 67 68 if (image->file_mode) > 69 memcpy(&fdt, image->segment[i].buf, sizeof(fdt)); 70 else if (copy_from_user(&fdt, image->segment[i].buf, sizeof(fdt))) 71 continue; 72 73 if (fdt_check_header(&fdt)) 74 continue; 75 76 internal->fdt_addr = (unsigned long) image->segment[i].mem; 77 break; 78 } 79 80 if (!internal->fdt_addr) { 81 pr_err("Device tree not included in the provided image\n"); 82 return -EINVAL; 83 } 84 85 /* Copy the assembler code for relocation to the control page */ 86 if (image->type != KEXEC_TYPE_CRASH) { 87 control_code_buffer = page_address(image->control_code_page); 88 control_code_buffer_sz = page_size(image->control_code_page); 89 90 if (unlikely(riscv_kexec_relocate_size > control_code_buffer_sz)) { 91 pr_err("Relocation code doesn't fit within a control page\n"); 92 return -EINVAL; 93 } 94 95 memcpy(control_code_buffer, riscv_kexec_relocate, 96 riscv_kexec_relocate_size); 97 98 /* Mark the control page executable */ 99 set_memory_x((unsigned long) control_code_buffer, 1); 100 } 101 102 return 0; 103 } 104 -- 0-DAY CI Kernel Test Service https://01.org/lkp