lkml.org 
[lkml]   [2020]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/8] asm-generic: fix unaligned access hamdling in raw_copy_{from,to}_user
On Fri, Sep 04, 2020 at 08:04:34PM +0200, Arnd Bergmann wrote:
> > if (__builtin_constant_p(n)) {
> > switch(n) {
> > case 1:
> > - *(u8 *)to = *(u8 __force *)from;
> > + *(u8 *)to = get_unaligned((u8 __force *)from);
> > return 0;
> > case 2:
> > - *(u16 *)to = *(u16 __force *)from;
> > + *(u16 *)to = get_unaligned((u16 __force *)from);
> > return 0;
>
> The change look correct and necessary, but I wonder if this could be done
> in a way that is a little easier on the compiler than the nested switch/case.
>
> If I see it right, __put_user() and __get_user() can probably
> be reduced to a plain put_unaligned() and get_unaligned() here,
> which would simplify these a lot.
>
> In turn it seems that the generic raw_copy_to_user() can just be the
> a plain memcpy(), IIRC the optimization for small sizes should also
> be done by modern compilers whenever they can.

Sure, I can look into that.

\
 
 \ /
  Last update: 2020-09-05 09:15    [W:1.812 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site