[PATCH -next v2 1/2] riscv: uaccess: rename __get/put_user_nocheck to __get/put_mem_nocheck

Andrew Jones ajones at ventanamicro.com
Fri Aug 26 00:43:18 PDT 2022


On Fri, Aug 26, 2022 at 02:33:47PM +0800, Tong Tiangen wrote:
> 
> 
> 在 2022/8/25 18:56, Andrew Jones 写道:
> > On Mon, Aug 15, 2022 at 03:20:24AM +0000, Tong Tiangen wrote:
> > > Current, The helpers __get/put_user_nocheck() is used by get/put_user() and
> > > __get/put_kernel_nofault(), which is not always uaccess, so the name with
> > > *user* is not appropriate.
> > > 
> > > Also rename xxx_user_xxx to xxx_mem_xx  on the call path of
> > > __get/put_user_nocheck()
> > > 
> > > Only refactor code without any functional changes.
> > > 
> > > Signed-off-by: Tong Tiangen <tongtiangen at huawei.com>
> > > ---
> > >   arch/riscv/include/asm/uaccess.h | 48 ++++++++++++++++----------------
> > >   1 file changed, 24 insertions(+), 24 deletions(-)
> > > 
> > > diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
> > > index 855450bed9f5..1370da055b44 100644
> > > --- a/arch/riscv/include/asm/uaccess.h
> > > +++ b/arch/riscv/include/asm/uaccess.h
> > > @@ -50,7 +50,7 @@
> > >    * call.
> > >    */
> > > -#define __get_user_asm(insn, x, ptr, err)			\
> > > +#define __get_mem_asm(insn, x, ptr, err)			\
> > >   do {								\
> > >   	__typeof__(x) __x;					\
> > >   	__asm__ __volatile__ (					\
> > > @@ -64,12 +64,12 @@ do {								\
> > >   } while (0)
> > >   #ifdef CONFIG_64BIT
> > > -#define __get_user_8(x, ptr, err) \
> > > -	__get_user_asm("ld", x, ptr, err)
> > > +#define __get_mem_8(x, ptr, err) \
> > > +	__get_mem_asm("ld", x, ptr, err)
> > >   #else /* !CONFIG_64BIT */
> > > -#define __get_user_8(x, ptr, err)				\
> > > +#define __get_mem_8(x, ptr, err)				\
> > >   do {								\
> > > -	u32 __user *__ptr = (u32 __user *)(ptr);		\
> > > +	u32 *__ptr = (u32 *)(ptr);				\
> > 
> > Doesn't casting away __user reduce sparse's utility?
> 
> From the call logic[1], the address passed into this macro is not
> necessarily __user. I understand that no problem will be introduced for
> sparse's utility.
> 
> In addition, there is no need to do a pointer conversion here, will be fixed
> next version.
> 
> [1] __get_kernel_nofault -> __get_mem_nocheck -> __get_mem_8

Yes, I understood that. My concern was for the times that the address was
__user as we'd no longer get that check for them.

Thanks,
drew



More information about the linux-riscv mailing list