[PATCH v3 1/6] x86/uaccess: Avoid barrier_nospec() in 64-bit copy_from_user()
Linus Torvalds
torvalds at linux-foundation.org
Wed Oct 30 13:03:31 AEDT 2024
On Mon, 28 Oct 2024 at 15:56, Josh Poimboeuf <jpoimboe at kernel.org> wrote:
>
> The barrier_nospec() in 64-bit copy_from_user() is slow. Instead use
> pointer masking to force the user pointer to all 1's if the access_ok()
> mispredicted true for an invalid address.
>
> The kernel test robot reports a 2.6% improvement in the per_thread_ops
> benchmark (see link below).
Hmm. So it strikes me that this still does the "access_ok()", but
that's pointless for the actual pointer masking case. One of the whole
points of the pointer masking is that we can just do this without
actually checking the address (or length) at all.
That's why the strncpy_from_user() has the pattern of
if (can_do_masked_user_access()) {
... don't worry about the size of the address space ..
and I think this code should do that too.
IOW, I think we can do even better than your patch with something
(UNTESTED!) like the attached.
That will also mean that any other architecture that starts doing the
user address masking trick will pick up on this automatically.
Hmm?
Linus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-patch
Size: 1433 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20241029/89073396/attachment.bin>
More information about the Linuxppc-dev
mailing list