Re: [PATCH] microblaze: remove CONFIG_SET_FS

From: Arnd Bergmann
Date: Fri Feb 11 2022 - 12:00:09 EST


On Fri, Feb 11, 2022 at 1:17 AM Stafford Horne <shorne@xxxxxxxxx> wrote:
> On Thu, Feb 10, 2022 at 08:31:05AM +0900, Stafford Horne wrote:

> > > Looking at it again, I wonder if it would help to use the __get_kernel_nofault()
> > > and __get_kernel_nofault() helpers as the default in
> > > include/asm-generic/uaccess.h.
> >
> > That would make sense. Perhaps also the __range_ok() function from OpenRISC
> > could move there as I think other architectures would also want to use that.

I have now uploaded a cleanup series to
https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/log/?h=set_fs

This uses the same access_ok() function across almost all
architectures, with the
exception of those that need something else, and I then I went further
and killed
off set_fs for everything other than ia64.

> > > I see it's identical to the openrisc version and would probably be the same
> > > for some of the other architectures that have no other use for
> > > set_fs(). That may
> > > help to do a bulk remove of set_fs for alpha, arc, csky, h8300, hexagon, nds32,
> > > nios2, um and extensa, leaving only ia64, sparc and sh.
> >
> > If you could add it into include/asm-generic/uaccess.h I can test changing my
> > patch to use it.
>
> Note, I would be happy to do the work to move these into include/asm-generic/uaccess.h.
> But as I see it the existing include/asm-generic/uaccess.h is for NOMMU. How
> should we go about having an MMU and NOMMU version? Should we move uaccess.h to
> uaccess-nommu.h? Or add more ifdefs to uaccess.h?

There are two parts of asm-generic/uaccess.h:

- the CONFIG_UACCESS_MEMCPYsection is fundamentally limited to nommu
targets and cannot be shared. Similarly, targets with an MMU must use a custom
implementation to get the correct fixups.

- the put_user/get_user implementation is fairly dumb, you can use these to
avoid having your own ones, but you still need copy_{to,from}_user, and
a custom implementation tends to produce better code.

So chances are that you won't want to use either one. In my new branch,
I added the common helpers to linux/uaccess.h and asm-generic/access-ok.h,
respectively, both of which are used everywhere now.

Arnd