]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/uaccess: Implement unsafe_copy_to_user() as a simple loop
authorChristophe Leroy <christophe.leroy@c-s.fr>
Fri, 17 Apr 2020 17:08:52 +0000 (17:08 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 30 Apr 2020 10:30:40 +0000 (20:30 +1000)
commit17bc43367fc2a720400d21c745db641c654c1e6b
treed3d03d7c6321de33147c211881dd76d9060c42dd
parent334710b1496af8a0960e70121f850e209c20958f
powerpc/uaccess: Implement unsafe_copy_to_user() as a simple loop

At the time being, unsafe_copy_to_user() is based on
raw_copy_to_user() which calls __copy_tofrom_user().

__copy_tofrom_user() is a big optimised function to copy big amount
of data. It aligns destinations to cache line in order to use
dcbz instruction.

Today unsafe_copy_to_user() is called only from filldir().
It is used to mainly copy small amount of data like filenames,
so __copy_tofrom_user() is not fit.

Also, unsafe_copy_to_user() is used within user_access_begin/end
sections. In those section, it is preferable to not call functions.

Rewrite unsafe_copy_to_user() as a macro that uses __put_user_goto().
We first perform a loop of long, then we finish with necessary
complements.

unsafe_copy_to_user() might be used in the near future to copy
fixed-size data, like pt_regs structs during signal processing.
Having it as a macro allows GCC to optimise it for instead when
it knows the size in advance, it can unloop loops, drop complements
when the size is a multiple of longs, etc ...

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/fe952112c29bf6a0a2778c9e6bbb4f4afd2c4258.1587143308.git.christophe.leroy@c-s.fr
arch/powerpc/include/asm/uaccess.h