Re: [PATCH] csky: uaccess.h: Coding convention with asm generic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 28, 2021 at 10:30 AM Guo Ren <guoren@xxxxxxxxxx> wrote:
> On Wed, Apr 28, 2021 at 11:18 AM Guenter Roeck <linux@xxxxxxxxxxxx> wrote:
> >
> > On Wed, Apr 21, 2021 at 08:54:15AM +0000, guoren@xxxxxxxxxx wrote:
> > > From: Guo Ren <guoren@xxxxxxxxxxxxxxxxx>
> > >
> > > Using asm-generic/uaccess.h to prevent duplicated code:
> > >  - Add user_addr_max which mentioned in generic uaccess.h
> > >  - Remove custom definitions of KERNEL/USER_DS, get/set_fs,
> > >    uaccess_kerenl
> > >  - Using generic extable.h instead of custom definitions in
> > >    uaccess.h
> > >
> > > Signed-off-by: Guo Ren <guoren@xxxxxxxxxxxxxxxxx>
> > > Cc: Arnd Bergmann <arnd@xxxxxxxx>
> >
> > Building csky:tinyconfig ... failed
> > --------------
> > Error log:
> > csky-linux-ld: fs/readdir.o: in function `__put_user_fn':
> > readdir.c:(.text+0x7c): undefined reference to `__put_user_bad'
> > csky-linux-ld: fs/readdir.o: in function `$d':
> > readdir.c:(.text+0x1bc): undefined reference to `__put_user_bad'
> > make[1]: *** [Makefile:1277: vmlinux] Error 1
> > make: *** [Makefile:222: __sub-make] Error 2
> It's a bug, I can't put __put_user_bad in __put_user_fn, and
> __put_user has done that:
>
> /*
>  * These are the main single-value transfer routines.  They automatically
>  * use the right size if we just have the right pointer type.
>  * This version just falls back to copy_{from,to}_user, which should
>  * provide a fast-path for small values.
>  */
> #define __put_user(x, ptr) \
> ({                                                              \
>         __typeof__(*(ptr)) __x = (x);                           \
>         int __pu_err = -EFAULT;                                 \
>         __chk_user_ptr(ptr);                                    \
>         switch (sizeof (*(ptr))) {                              \
>         case 1:                                                 \
>         case 2:                                                 \
>         case 4:                                                 \
>         case 8:                                                 \
>                 __pu_err = __put_user_fn(sizeof (*(ptr)),       \
>                                          ptr, &__x);            \
>                 break;                                          \
>         default:                                                \
>                 __put_user_bad();                               \
>                 break;                                          \
>          }                                                      \
>         __pu_err;                                               \
> })

Actually, please don't use the asm-generic __put_user version based
on copy_to_user, we probably have killed it off long ago.

We might want to come up with a new version of asm-generic/uaccess.h
that actually makes it easier to have a sane per-architecture
implementation of the low-level accessors without set_fs().

I've added Christoph to Cc here, he probably has some ideas
on where we should be heading.

One noteworthy aspect is that almost nothing users the low-level
__get_user()/__put_user() helpers any more outside of architecture
specific code, so we may not need to have separate versions
for much longer.

      Arnd



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux