Message ID | 20240625040500.1788-4-jszhang@kernel.org (mailing list archive) |
---|---|
State | Changes Requested, archived |
Headers | show |
Series | riscv: uaccess: optimizations | expand |
Hi Jisheng, kernel test robot noticed the following build errors: [auto build test ERROR on linus/master] [also build test ERROR on v6.10-rc6 next-20240703] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Jisheng-Zhang/riscv-implement-user_access_begin-and-families/20240626-005352 base: linus/master patch link: https://lore.kernel.org/r/20240625040500.1788-4-jszhang%40kernel.org patch subject: [PATCH 3/4] riscv: uaccess: use 'asm goto' for put_user() config: riscv-randconfig-r121-20240705 (https://download.01.org/0day-ci/archive/20240705/202407051058.kE7ADWxJ-lkp@intel.com/config) compiler: riscv32-linux-gcc (GCC) 13.2.0 reproduce: (https://download.01.org/0day-ci/archive/20240705/202407051058.kE7ADWxJ-lkp@intel.com/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 | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202407051058.kE7ADWxJ-lkp@intel.com/ All errors (new ones prefixed by >>): In file included from include/linux/uaccess.h:11, from include/linux/sched/task.h:13, from include/linux/sched/signal.h:9, from include/linux/rcuwait.h:6, from include/linux/percpu-rwsem.h:7, from include/linux/fs.h:33, from include/linux/compat.h:17, from arch/riscv/include/asm/elf.h:12, from include/linux/elf.h:6, from include/linux/module.h:19, from include/linux/device/driver.h:21, from include/linux/device.h:32, from include/linux/node.h:18, from include/linux/cpu.h:17, from arch/riscv/kernel/process.c:10: arch/riscv/kernel/process.c: In function 'get_unalign_ctl': >> arch/riscv/include/asm/uaccess.h:211:46: error: expected ')' before ':' token 211 | "m" (__ptr[__MSW]) : : label); \ | ^ arch/riscv/include/asm/uaccess.h:228:17: note: in expansion of macro '__put_user_8' 228 | __put_user_8((x), __gu_ptr, label); \ | ^~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:238:9: note: in expansion of macro '__put_user_nocheck' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:274:9: note: in expansion of macro '__put_user_error' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:301:17: note: in expansion of macro '__put_user' 301 | __put_user((x), __p) : \ | ^~~~~~~~~~ arch/riscv/kernel/process.c:57:16: note: in expansion of macro 'put_user' 57 | return put_user(tsk->thread.align_ctl, (unsigned long __user *)adr); | ^~~~~~~~ arch/riscv/include/asm/uaccess.h:202:30: note: to match this '(' 202 | __asm__ __volatile__ ( \ | ^ arch/riscv/include/asm/uaccess.h:228:17: note: in expansion of macro '__put_user_8' 228 | __put_user_8((x), __gu_ptr, label); \ | ^~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:238:9: note: in expansion of macro '__put_user_nocheck' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:274:9: note: in expansion of macro '__put_user_error' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:301:17: note: in expansion of macro '__put_user' 301 | __put_user((x), __p) : \ | ^~~~~~~~~~ arch/riscv/kernel/process.c:57:16: note: in expansion of macro 'put_user' 57 | return put_user(tsk->thread.align_ctl, (unsigned long __user *)adr); | ^~~~~~~~ -- In file included from include/linux/uaccess.h:11, from include/linux/sched/task.h:13, from include/linux/sched/signal.h:9, from include/linux/rcuwait.h:6, from include/linux/percpu-rwsem.h:7, from include/linux/fs.h:33, from include/linux/compat.h:17, from arch/riscv/kernel/signal.c:9: arch/riscv/kernel/signal.c: In function 'setup_sigcontext': >> arch/riscv/include/asm/uaccess.h:211:46: error: expected ')' before ':' token 211 | "m" (__ptr[__MSW]) : : label); \ | ^ arch/riscv/include/asm/uaccess.h:228:17: note: in expansion of macro '__put_user_8' 228 | __put_user_8((x), __gu_ptr, label); \ | ^~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:238:9: note: in expansion of macro '__put_user_nocheck' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:274:9: note: in expansion of macro '__put_user_error' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^~~~~~~~~~~~~~~~ arch/riscv/kernel/signal.c:290:16: note: in expansion of macro '__put_user' 290 | err |= __put_user(0, &sc->sc_extdesc.reserved); | ^~~~~~~~~~ arch/riscv/include/asm/uaccess.h:202:30: note: to match this '(' 202 | __asm__ __volatile__ ( \ | ^ arch/riscv/include/asm/uaccess.h:228:17: note: in expansion of macro '__put_user_8' 228 | __put_user_8((x), __gu_ptr, label); \ | ^~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:238:9: note: in expansion of macro '__put_user_nocheck' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:274:9: note: in expansion of macro '__put_user_error' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^~~~~~~~~~~~~~~~ arch/riscv/kernel/signal.c:290:16: note: in expansion of macro '__put_user' 290 | err |= __put_user(0, &sc->sc_extdesc.reserved); | ^~~~~~~~~~ >> arch/riscv/include/asm/uaccess.h:211:46: error: expected ')' before ':' token 211 | "m" (__ptr[__MSW]) : : label); \ | ^ arch/riscv/include/asm/uaccess.h:228:17: note: in expansion of macro '__put_user_8' 228 | __put_user_8((x), __gu_ptr, label); \ | ^~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:238:9: note: in expansion of macro '__put_user_nocheck' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:274:9: note: in expansion of macro '__put_user_error' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^~~~~~~~~~~~~~~~ arch/riscv/kernel/signal.c:292:16: note: in expansion of macro '__put_user' 292 | err |= __put_user(END_MAGIC, &sc_ext_ptr->magic); | ^~~~~~~~~~ arch/riscv/include/asm/uaccess.h:202:30: note: to match this '(' 202 | __asm__ __volatile__ ( \ | ^ arch/riscv/include/asm/uaccess.h:228:17: note: in expansion of macro '__put_user_8' 228 | __put_user_8((x), __gu_ptr, label); \ | ^~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:238:9: note: in expansion of macro '__put_user_nocheck' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:274:9: note: in expansion of macro '__put_user_error' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^~~~~~~~~~~~~~~~ arch/riscv/kernel/signal.c:292:16: note: in expansion of macro '__put_user' 292 | err |= __put_user(END_MAGIC, &sc_ext_ptr->magic); | ^~~~~~~~~~ >> arch/riscv/include/asm/uaccess.h:211:46: error: expected ')' before ':' token 211 | "m" (__ptr[__MSW]) : : label); \ | ^ arch/riscv/include/asm/uaccess.h:228:17: note: in expansion of macro '__put_user_8' 228 | __put_user_8((x), __gu_ptr, label); \ | ^~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:238:9: note: in expansion of macro '__put_user_nocheck' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:274:9: note: in expansion of macro '__put_user_error' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^~~~~~~~~~~~~~~~ arch/riscv/kernel/signal.c:293:16: note: in expansion of macro '__put_user' 293 | err |= __put_user(END_HDR_SIZE, &sc_ext_ptr->size); | ^~~~~~~~~~ arch/riscv/include/asm/uaccess.h:202:30: note: to match this '(' 202 | __asm__ __volatile__ ( \ | ^ arch/riscv/include/asm/uaccess.h:228:17: note: in expansion of macro '__put_user_8' 228 | __put_user_8((x), __gu_ptr, label); \ | ^~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:238:9: note: in expansion of macro '__put_user_nocheck' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:274:9: note: in expansion of macro '__put_user_error' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^~~~~~~~~~~~~~~~ arch/riscv/kernel/signal.c:293:16: note: in expansion of macro '__put_user' 293 | err |= __put_user(END_HDR_SIZE, &sc_ext_ptr->size); | ^~~~~~~~~~ arch/riscv/kernel/signal.c: In function 'setup_rt_frame': >> arch/riscv/include/asm/uaccess.h:211:46: error: expected ')' before ':' token 211 | "m" (__ptr[__MSW]) : : label); \ | ^ arch/riscv/include/asm/uaccess.h:228:17: note: in expansion of macro '__put_user_8' 228 | __put_user_8((x), __gu_ptr, label); \ | ^~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:238:9: note: in expansion of macro '__put_user_nocheck' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:274:9: note: in expansion of macro '__put_user_error' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^~~~~~~~~~~~~~~~ arch/riscv/kernel/signal.c:336:16: note: in expansion of macro '__put_user' 336 | err |= __put_user(0, &frame->uc.uc_flags); | ^~~~~~~~~~ arch/riscv/include/asm/uaccess.h:202:30: note: to match this '(' 202 | __asm__ __volatile__ ( \ | ^ arch/riscv/include/asm/uaccess.h:228:17: note: in expansion of macro '__put_user_8' 228 | __put_user_8((x), __gu_ptr, label); \ | ^~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:238:9: note: in expansion of macro '__put_user_nocheck' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:274:9: note: in expansion of macro '__put_user_error' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^~~~~~~~~~~~~~~~ arch/riscv/kernel/signal.c:336:16: note: in expansion of macro '__put_user' 336 | err |= __put_user(0, &frame->uc.uc_flags); | ^~~~~~~~~~ >> arch/riscv/include/asm/uaccess.h:211:46: error: expected ')' before ':' token 211 | "m" (__ptr[__MSW]) : : label); \ | ^ arch/riscv/include/asm/uaccess.h:228:17: note: in expansion of macro '__put_user_8' 228 | __put_user_8((x), __gu_ptr, label); \ | ^~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:238:9: note: in expansion of macro '__put_user_nocheck' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:274:9: note: in expansion of macro '__put_user_error' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^~~~~~~~~~~~~~~~ arch/riscv/kernel/signal.c:337:16: note: in expansion of macro '__put_user' 337 | err |= __put_user(NULL, &frame->uc.uc_link); | ^~~~~~~~~~ arch/riscv/include/asm/uaccess.h:202:30: note: to match this '(' 202 | __asm__ __volatile__ ( \ | ^ arch/riscv/include/asm/uaccess.h:228:17: note: in expansion of macro '__put_user_8' 228 | __put_user_8((x), __gu_ptr, label); \ | ^~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:238:9: note: in expansion of macro '__put_user_nocheck' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:274:9: note: in expansion of macro '__put_user_error' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^~~~~~~~~~~~~~~~ arch/riscv/kernel/signal.c:337:16: note: in expansion of macro '__put_user' 337 | err |= __put_user(NULL, &frame->uc.uc_link); | ^~~~~~~~~~ -- In file included from include/linux/uaccess.h:11, from include/linux/sched/task.h:13, from include/linux/sched/signal.h:9, from include/linux/rcuwait.h:6, from include/linux/percpu-rwsem.h:7, from include/linux/fs.h:33, from include/uapi/linux/aio_abi.h:31, from include/linux/syscalls.h:82, from arch/riscv/kernel/sys_hwprobe.c:7: arch/riscv/kernel/sys_hwprobe.c: In function 'hwprobe_get_values': >> arch/riscv/include/asm/uaccess.h:211:46: error: expected ')' before ':' token 211 | "m" (__ptr[__MSW]) : : label); \ | ^ arch/riscv/include/asm/uaccess.h:228:17: note: in expansion of macro '__put_user_8' 228 | __put_user_8((x), __gu_ptr, label); \ | ^~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:238:9: note: in expansion of macro '__put_user_nocheck' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:274:9: note: in expansion of macro '__put_user_error' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:301:17: note: in expansion of macro '__put_user' 301 | __put_user((x), __p) : \ | ^~~~~~~~~~ arch/riscv/kernel/sys_hwprobe.c:278:23: note: in expansion of macro 'put_user' 278 | ret = put_user(pair.key, &pairs->key); | ^~~~~~~~ arch/riscv/include/asm/uaccess.h:202:30: note: to match this '(' 202 | __asm__ __volatile__ ( \ | ^ arch/riscv/include/asm/uaccess.h:228:17: note: in expansion of macro '__put_user_8' 228 | __put_user_8((x), __gu_ptr, label); \ | ^~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:238:9: note: in expansion of macro '__put_user_nocheck' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:274:9: note: in expansion of macro '__put_user_error' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:301:17: note: in expansion of macro '__put_user' 301 | __put_user((x), __p) : \ | ^~~~~~~~~~ arch/riscv/kernel/sys_hwprobe.c:278:23: note: in expansion of macro 'put_user' 278 | ret = put_user(pair.key, &pairs->key); | ^~~~~~~~ >> arch/riscv/include/asm/uaccess.h:211:46: error: expected ')' before ':' token 211 | "m" (__ptr[__MSW]) : : label); \ | ^ arch/riscv/include/asm/uaccess.h:228:17: note: in expansion of macro '__put_user_8' 228 | __put_user_8((x), __gu_ptr, label); \ | ^~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:238:9: note: in expansion of macro '__put_user_nocheck' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:274:9: note: in expansion of macro '__put_user_error' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:301:17: note: in expansion of macro '__put_user' 301 | __put_user((x), __p) : \ | ^~~~~~~~~~ arch/riscv/kernel/sys_hwprobe.c:280:31: note: in expansion of macro 'put_user' 280 | ret = put_user(pair.value, &pairs->value); | ^~~~~~~~ arch/riscv/include/asm/uaccess.h:202:30: note: to match this '(' 202 | __asm__ __volatile__ ( \ | ^ arch/riscv/include/asm/uaccess.h:228:17: note: in expansion of macro '__put_user_8' 228 | __put_user_8((x), __gu_ptr, label); \ | ^~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:238:9: note: in expansion of macro '__put_user_nocheck' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:274:9: note: in expansion of macro '__put_user_error' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^~~~~~~~~~~~~~~~ arch/riscv/include/asm/uaccess.h:301:17: note: in expansion of macro '__put_user' 301 | __put_user((x), __p) : \ | ^~~~~~~~~~ arch/riscv/kernel/sys_hwprobe.c:280:31: note: in expansion of macro 'put_user' 280 | ret = put_user(pair.value, &pairs->value); | ^~~~~~~~ vim +211 arch/riscv/include/asm/uaccess.h 193 194 #ifdef CONFIG_64BIT 195 #define __put_user_8(x, ptr, label) \ 196 __put_user_asm("sd", x, ptr, label) 197 #else /* !CONFIG_64BIT */ 198 #define __put_user_8(x, ptr, label) \ 199 do { \ 200 u32 __user *__ptr = (u32 __user *)(ptr); \ 201 u64 __x = (__typeof__((x)-(x)))(x); \ 202 __asm__ __volatile__ ( \ 203 "1:\n" \ 204 " sw %z0, %2\n" \ 205 "2:\n" \ 206 " sw %z1, %3\n" \ 207 _ASM_EXTABLE(1b, %l4) \ 208 _ASM_EXTABLE(2b, %l4) \ 209 : : "rJ" (__x), "rJ" (__x >> 32), \ 210 "m" (__ptr[__LSW]), \ > 211 "m" (__ptr[__MSW]) : : label); \ 212 } while (0) 213 #endif /* CONFIG_64BIT */ 214
Hi Jisheng, kernel test robot noticed the following build errors: [auto build test ERROR on linus/master] [also build test ERROR on v6.10-rc6 next-20240703] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Jisheng-Zhang/riscv-implement-user_access_begin-and-families/20240626-005352 base: linus/master patch link: https://lore.kernel.org/r/20240625040500.1788-4-jszhang%40kernel.org patch subject: [PATCH 3/4] riscv: uaccess: use 'asm goto' for put_user() config: riscv-randconfig-r071-20240705 (https://download.01.org/0day-ci/archive/20240706/202407060732.wjARQ4O7-lkp@intel.com/config) compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project a0c6b8aef853eedaa0980f07c0a502a5a8a9740e) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240706/202407060732.wjARQ4O7-lkp@intel.com/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 | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202407060732.wjARQ4O7-lkp@intel.com/ All errors (new ones prefixed by >>): In file included from block/ioctl.c:4: In file included from include/linux/blkdev.h:9: In file included from include/linux/blk_types.h:10: In file included from include/linux/bvec.h:10: In file included from include/linux/highmem.h:8: In file included from include/linux/cacheflush.h:5: In file included from arch/riscv/include/asm/cacheflush.h:9: In file included from include/linux/mm.h:2253: include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion] 514 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_" | ~~~~~~~~~~~ ^ ~~~ >> block/ioctl.c:236:9: error: expected ')' 236 | return put_user(val, argp); | ^ arch/riscv/include/asm/uaccess.h:301:3: note: expanded from macro 'put_user' 301 | __put_user((x), __p) : \ | ^ arch/riscv/include/asm/uaccess.h:274:2: note: expanded from macro '__put_user' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^ arch/riscv/include/asm/uaccess.h:238:2: note: expanded from macro '__put_user_error' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^ arch/riscv/include/asm/uaccess.h:228:3: note: expanded from macro '__put_user_nocheck' 228 | __put_user_8((x), __gu_ptr, label); \ | ^ arch/riscv/include/asm/uaccess.h:211:25: note: expanded from macro '__put_user_8' 211 | "m" (__ptr[__MSW]) : : label); \ | ^ block/ioctl.c:241:9: error: expected ')' 241 | return put_user(val, argp); | ^ arch/riscv/include/asm/uaccess.h:301:3: note: expanded from macro 'put_user' 301 | __put_user((x), __p) : \ | ^ arch/riscv/include/asm/uaccess.h:274:2: note: expanded from macro '__put_user' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^ arch/riscv/include/asm/uaccess.h:238:2: note: expanded from macro '__put_user_error' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^ arch/riscv/include/asm/uaccess.h:228:3: note: expanded from macro '__put_user_nocheck' 228 | __put_user_8((x), __gu_ptr, label); \ | ^ arch/riscv/include/asm/uaccess.h:211:25: note: expanded from macro '__put_user_8' 211 | "m" (__ptr[__MSW]) : : label); \ | ^ block/ioctl.c:246:9: error: expected ')' 246 | return put_user(val, argp); | ^ arch/riscv/include/asm/uaccess.h:301:3: note: expanded from macro 'put_user' 301 | __put_user((x), __p) : \ | ^ arch/riscv/include/asm/uaccess.h:274:2: note: expanded from macro '__put_user' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^ arch/riscv/include/asm/uaccess.h:238:2: note: expanded from macro '__put_user_error' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^ arch/riscv/include/asm/uaccess.h:228:3: note: expanded from macro '__put_user_nocheck' 228 | __put_user_8((x), __gu_ptr, label); \ | ^ arch/riscv/include/asm/uaccess.h:211:25: note: expanded from macro '__put_user_8' 211 | "m" (__ptr[__MSW]) : : label); \ | ^ block/ioctl.c:251:9: error: expected ')' 251 | return put_user(val, argp); | ^ arch/riscv/include/asm/uaccess.h:301:3: note: expanded from macro 'put_user' 301 | __put_user((x), __p) : \ | ^ arch/riscv/include/asm/uaccess.h:274:2: note: expanded from macro '__put_user' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^ arch/riscv/include/asm/uaccess.h:238:2: note: expanded from macro '__put_user_error' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^ arch/riscv/include/asm/uaccess.h:228:3: note: expanded from macro '__put_user_nocheck' 228 | __put_user_8((x), __gu_ptr, label); \ | ^ arch/riscv/include/asm/uaccess.h:211:25: note: expanded from macro '__put_user_8' 211 | "m" (__ptr[__MSW]) : : label); \ | ^ block/ioctl.c:256:9: error: expected ')' 256 | return put_user(val, argp); | ^ arch/riscv/include/asm/uaccess.h:301:3: note: expanded from macro 'put_user' 301 | __put_user((x), __p) : \ | ^ arch/riscv/include/asm/uaccess.h:274:2: note: expanded from macro '__put_user' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^ arch/riscv/include/asm/uaccess.h:238:2: note: expanded from macro '__put_user_error' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^ arch/riscv/include/asm/uaccess.h:228:3: note: expanded from macro '__put_user_nocheck' 228 | __put_user_8((x), __gu_ptr, label); \ | ^ arch/riscv/include/asm/uaccess.h:211:25: note: expanded from macro '__put_user_8' 211 | "m" (__ptr[__MSW]) : : label); \ | ^ block/ioctl.c:261:9: error: expected ')' 261 | return put_user(val, argp); | ^ arch/riscv/include/asm/uaccess.h:301:3: note: expanded from macro 'put_user' 301 | __put_user((x), __p) : \ | ^ arch/riscv/include/asm/uaccess.h:274:2: note: expanded from macro '__put_user' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^ arch/riscv/include/asm/uaccess.h:238:2: note: expanded from macro '__put_user_error' 238 | __put_user_nocheck(x, ptr, err_label); \ -- In file included from block/bsg.c:8: In file included from include/linux/blkdev.h:9: In file included from include/linux/blk_types.h:10: In file included from include/linux/bvec.h:10: In file included from include/linux/highmem.h:8: In file included from include/linux/cacheflush.h:5: In file included from arch/riscv/include/asm/cacheflush.h:9: In file included from include/linux/mm.h:2253: include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion] 514 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_" | ~~~~~~~~~~~ ^ ~~~ >> block/bsg.c:89:9: error: expected ')' 89 | return put_user(READ_ONCE(bd->max_queue), uarg); | ^ arch/riscv/include/asm/uaccess.h:301:3: note: expanded from macro 'put_user' 301 | __put_user((x), __p) : \ | ^ arch/riscv/include/asm/uaccess.h:274:2: note: expanded from macro '__put_user' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^ arch/riscv/include/asm/uaccess.h:238:2: note: expanded from macro '__put_user_error' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^ arch/riscv/include/asm/uaccess.h:228:3: note: expanded from macro '__put_user_nocheck' 228 | __put_user_8((x), __gu_ptr, label); \ | ^ arch/riscv/include/asm/uaccess.h:211:25: note: expanded from macro '__put_user_8' 211 | "m" (__ptr[__MSW]) : : label); \ | ^ block/bsg.c:125:10: error: expected ')' 125 | return put_user(30527, intp); | ^ arch/riscv/include/asm/uaccess.h:301:3: note: expanded from macro 'put_user' 301 | __put_user((x), __p) : \ | ^ arch/riscv/include/asm/uaccess.h:274:2: note: expanded from macro '__put_user' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^ arch/riscv/include/asm/uaccess.h:238:2: note: expanded from macro '__put_user_error' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^ arch/riscv/include/asm/uaccess.h:228:3: note: expanded from macro '__put_user_nocheck' 228 | __put_user_8((x), __gu_ptr, label); \ | ^ arch/riscv/include/asm/uaccess.h:211:25: note: expanded from macro '__put_user_8' 211 | "m" (__ptr[__MSW]) : : label); \ | ^ block/bsg.c:127:10: error: expected ')' 127 | return put_user(0, intp); | ^ arch/riscv/include/asm/uaccess.h:301:3: note: expanded from macro 'put_user' 301 | __put_user((x), __p) : \ | ^ arch/riscv/include/asm/uaccess.h:274:2: note: expanded from macro '__put_user' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^ arch/riscv/include/asm/uaccess.h:238:2: note: expanded from macro '__put_user_error' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^ arch/riscv/include/asm/uaccess.h:228:3: note: expanded from macro '__put_user_nocheck' 228 | __put_user_8((x), __gu_ptr, label); \ | ^ arch/riscv/include/asm/uaccess.h:211:25: note: expanded from macro '__put_user_8' 211 | "m" (__ptr[__MSW]) : : label); \ | ^ block/bsg.c:129:10: error: expected ')' 129 | return put_user(0, intp); | ^ arch/riscv/include/asm/uaccess.h:301:3: note: expanded from macro 'put_user' 301 | __put_user((x), __p) : \ | ^ arch/riscv/include/asm/uaccess.h:274:2: note: expanded from macro '__put_user' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^ arch/riscv/include/asm/uaccess.h:238:2: note: expanded from macro '__put_user_error' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^ arch/riscv/include/asm/uaccess.h:228:3: note: expanded from macro '__put_user_nocheck' 228 | __put_user_8((x), __gu_ptr, label); \ | ^ arch/riscv/include/asm/uaccess.h:211:25: note: expanded from macro '__put_user_8' 211 | "m" (__ptr[__MSW]) : : label); \ | ^ block/bsg.c:138:10: error: expected ')' 138 | return put_user(min(bd->reserved_size, queue_max_bytes(q)), | ^ arch/riscv/include/asm/uaccess.h:301:3: note: expanded from macro 'put_user' 301 | __put_user((x), __p) : \ | ^ arch/riscv/include/asm/uaccess.h:274:2: note: expanded from macro '__put_user' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^ arch/riscv/include/asm/uaccess.h:238:2: note: expanded from macro '__put_user_error' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^ arch/riscv/include/asm/uaccess.h:228:3: note: expanded from macro '__put_user_nocheck' 228 | __put_user_8((x), __gu_ptr, label); \ | ^ arch/riscv/include/asm/uaccess.h:211:25: note: expanded from macro '__put_user_8' 211 | "m" (__ptr[__MSW]) : : label); \ | ^ block/bsg.c:149:10: error: expected ')' 149 | return put_user(1, intp); | ^ arch/riscv/include/asm/uaccess.h:301:3: note: expanded from macro 'put_user' 301 | __put_user((x), __p) : \ | ^ arch/riscv/include/asm/uaccess.h:274:2: note: expanded from macro '__put_user' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^ arch/riscv/include/asm/uaccess.h:238:2: note: expanded from macro '__put_user_error' 238 | __put_user_nocheck(x, ptr, err_label); \ -- In file included from fs/read_write.c:14: In file included from include/linux/fsnotify.h:16: In file included from include/linux/audit.h:13: In file included from include/linux/ptrace.h:10: In file included from include/linux/pid_namespace.h:7: In file included from include/linux/mm.h:2253: include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion] 514 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_" | ~~~~~~~~~~~ ^ ~~~ >> fs/read_write.c:1340:16: error: expected ')' 1340 | if (unlikely(put_user(pos, offset))) | ^ arch/riscv/include/asm/uaccess.h:301:3: note: expanded from macro 'put_user' 301 | __put_user((x), __p) : \ | ^ arch/riscv/include/asm/uaccess.h:274:2: note: expanded from macro '__put_user' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^ arch/riscv/include/asm/uaccess.h:238:2: note: expanded from macro '__put_user_error' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^ arch/riscv/include/asm/uaccess.h:228:3: note: expanded from macro '__put_user_nocheck' 228 | __put_user_8((x), __gu_ptr, label); \ | ^ arch/riscv/include/asm/uaccess.h:211:25: note: expanded from macro '__put_user_8' 211 | "m" (__ptr[__MSW]) : : label); \ | ^ fs/read_write.c:1357:16: error: expected ')' 1357 | if (unlikely(put_user(pos, offset))) | ^ arch/riscv/include/asm/uaccess.h:301:3: note: expanded from macro 'put_user' 301 | __put_user((x), __p) : \ | ^ arch/riscv/include/asm/uaccess.h:274:2: note: expanded from macro '__put_user' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^ arch/riscv/include/asm/uaccess.h:238:2: note: expanded from macro '__put_user_error' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^ arch/riscv/include/asm/uaccess.h:228:3: note: expanded from macro '__put_user_nocheck' 228 | __put_user_8((x), __gu_ptr, label); \ | ^ arch/riscv/include/asm/uaccess.h:211:25: note: expanded from macro '__put_user_8' 211 | "m" (__ptr[__MSW]) : : label); \ | ^ 1 warning and 2 errors generated. -- In file included from fs/file_table.c:17: In file included from include/linux/security.h:33: In file included from include/linux/mm.h:2253: include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion] 514 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_" | ~~~~~~~~~~~ ^ ~~~ In file included from fs/file_table.c:19: >> include/linux/eventpoll.h:81:6: error: expected ')' 81 | if (__put_user(revents, &uevent->events) || | ^ arch/riscv/include/asm/uaccess.h:274:2: note: expanded from macro '__put_user' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^ arch/riscv/include/asm/uaccess.h:238:2: note: expanded from macro '__put_user_error' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^ arch/riscv/include/asm/uaccess.h:228:3: note: expanded from macro '__put_user_nocheck' 228 | __put_user_8((x), __gu_ptr, label); \ | ^ arch/riscv/include/asm/uaccess.h:211:25: note: expanded from macro '__put_user_8' 211 | "m" (__ptr[__MSW]) : : label); \ | ^ In file included from fs/file_table.c:19: include/linux/eventpoll.h:82:6: error: expected ')' 82 | __put_user(data, &uevent->data)) | ^ arch/riscv/include/asm/uaccess.h:274:2: note: expanded from macro '__put_user' 274 | __put_user_error(__val, __gu_ptr, __pu_err); \ | ^ arch/riscv/include/asm/uaccess.h:238:2: note: expanded from macro '__put_user_error' 238 | __put_user_nocheck(x, ptr, err_label); \ | ^ arch/riscv/include/asm/uaccess.h:228:3: note: expanded from macro '__put_user_nocheck' 228 | __put_user_8((x), __gu_ptr, label); \ | ^ arch/riscv/include/asm/uaccess.h:211:25: note: expanded from macro '__put_user_8' 211 | "m" (__ptr[__MSW]) : : label); \ | ^ 1 warning and 2 errors generated. .. vim +236 block/ioctl.c 66ba32dc167202c block/ioctl.c Martin K. Petersen 2012-09-18 233 9b81648cb5e3ae7 block/ioctl.c Arnd Bergmann 2019-11-29 234 static int put_ushort(unsigned short __user *argp, unsigned short val) ^1da177e4c3f415 drivers/block/ioctl.c Linus Torvalds 2005-04-16 235 { 9b81648cb5e3ae7 block/ioctl.c Arnd Bergmann 2019-11-29 @236 return put_user(val, argp); ^1da177e4c3f415 drivers/block/ioctl.c Linus Torvalds 2005-04-16 237 } ^1da177e4c3f415 drivers/block/ioctl.c Linus Torvalds 2005-04-16 238
diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h index 84b084e388a7..d8c44705b61d 100644 --- a/arch/riscv/include/asm/uaccess.h +++ b/arch/riscv/include/asm/uaccess.h @@ -181,61 +181,66 @@ do { \ ((x) = (__force __typeof__(x))0, -EFAULT); \ }) -#define __put_user_asm(insn, x, ptr, err) \ +#define __put_user_asm(insn, x, ptr, label) \ do { \ __typeof__(*(ptr)) __x = x; \ - __asm__ __volatile__ ( \ + asm goto( \ "1:\n" \ - " " insn " %z1, %2\n" \ - "2:\n" \ - _ASM_EXTABLE_UACCESS_ERR(1b, 2b, %0) \ - : "+r" (err) \ - : "rJ" (__x), "m"(*(ptr))); \ + " " insn " %z0, %1\n" \ + _ASM_EXTABLE(1b, %l2) \ + : : "rJ" (__x), "m"(*(ptr)) : : label); \ } while (0) #ifdef CONFIG_64BIT -#define __put_user_8(x, ptr, err) \ - __put_user_asm("sd", x, ptr, err) +#define __put_user_8(x, ptr, label) \ + __put_user_asm("sd", x, ptr, label) #else /* !CONFIG_64BIT */ -#define __put_user_8(x, ptr, err) \ +#define __put_user_8(x, ptr, label) \ do { \ u32 __user *__ptr = (u32 __user *)(ptr); \ u64 __x = (__typeof__((x)-(x)))(x); \ __asm__ __volatile__ ( \ "1:\n" \ - " sw %z1, %3\n" \ + " sw %z0, %2\n" \ "2:\n" \ - " sw %z2, %4\n" \ - "3:\n" \ - _ASM_EXTABLE_UACCESS_ERR(1b, 3b, %0) \ - _ASM_EXTABLE_UACCESS_ERR(2b, 3b, %0) \ - : "+r" (err) \ - : "rJ" (__x), "rJ" (__x >> 32), \ + " sw %z1, %3\n" \ + _ASM_EXTABLE(1b, %l4) \ + _ASM_EXTABLE(2b, %l4) \ + : : "rJ" (__x), "rJ" (__x >> 32), \ "m" (__ptr[__LSW]), \ - "m" (__ptr[__MSW])); \ + "m" (__ptr[__MSW]) : : label); \ } while (0) #endif /* CONFIG_64BIT */ -#define __put_user_nocheck(x, __gu_ptr, __pu_err) \ +#define __put_user_nocheck(x, __gu_ptr, label) \ do { \ switch (sizeof(*__gu_ptr)) { \ case 1: \ - __put_user_asm("sb", (x), __gu_ptr, __pu_err); \ + __put_user_asm("sb", (x), __gu_ptr, label); \ break; \ case 2: \ - __put_user_asm("sh", (x), __gu_ptr, __pu_err); \ + __put_user_asm("sh", (x), __gu_ptr, label); \ break; \ case 4: \ - __put_user_asm("sw", (x), __gu_ptr, __pu_err); \ + __put_user_asm("sw", (x), __gu_ptr, label); \ break; \ case 8: \ - __put_user_8((x), __gu_ptr, __pu_err); \ + __put_user_8((x), __gu_ptr, label); \ break; \ default: \ BUILD_BUG(); \ } \ } while (0) +#define __put_user_error(x, ptr, err) \ +do { \ + __label__ err_label; \ + __put_user_nocheck(x, ptr, err_label); \ + break; \ +err_label: \ + (err) = -EFAULT; \ +} while (0) + /** * __put_user: - Write a simple value into user space, with less checking. * @x: Value to copy to user space. @@ -266,7 +271,7 @@ do { \ __chk_user_ptr(__gu_ptr); \ \ __enable_user_access(); \ - __put_user_nocheck(__val, __gu_ptr, __pu_err); \ + __put_user_error(__val, __gu_ptr, __pu_err); \ __disable_user_access(); \ \ __pu_err; \ @@ -340,13 +345,7 @@ do { \ } while (0) #define __put_kernel_nofault(dst, src, type, err_label) \ -do { \ - long __kr_err = 0; \ - \ - __put_user_nocheck(*((type *)(src)), (type *)(dst), __kr_err); \ - if (unlikely(__kr_err)) \ - goto err_label; \ -} while (0) + __put_user_nocheck(*((type *)(src)), (type *)(dst), err_label); static __must_check __always_inline bool user_access_begin(const void __user *ptr, size_t len) { @@ -361,11 +360,8 @@ static __must_check __always_inline bool user_access_begin(const void __user *pt static inline unsigned long user_access_save(void) { return 0UL; } static inline void user_access_restore(unsigned long enabled) { } -#define unsafe_put_user(x, ptr, label) do { \ - long __kr_err = 0; \ - __put_user_nocheck(x, (ptr), __kr_err); \ - if (__kr_err) goto label; \ -} while (0) +#define unsafe_put_user(x, ptr, label) \ + __put_user_nocheck(x, (ptr), label); #define unsafe_get_user(x, ptr, label) do { \ long __kr_err = 0; \
'asm goto' generates noticeably better code since we don't need to test the error etc, the exception just jumps to the error handling directly. Signed-off-by: Jisheng Zhang <jszhang@kernel.org> --- arch/riscv/include/asm/uaccess.h | 68 +++++++++++++++----------------- 1 file changed, 32 insertions(+), 36 deletions(-)