Re: [PATCH v1 1/4] lib: introduce copy_struct_from_user() helper
From: Linus Torvalds
Date: Wed Sep 25 2019 - 16:23:51 EST
On Wed, Sep 25, 2019 at 12:43 PM Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
>
> FWIW, I would probably add a kernel-space analogue of that thing at the
> same time - check that an area is all-zeroes is not all that rare.
Hmm. Maybe.
> Another thing is that for s390 we almost certainly want something better
> than word-by-word. IIRC, word-sized userland accesses really hurt there.
> It's nowhere near as critical as with strncpy_from_user(), but with the
> same underlying issue.
Well, s390 does have those magic "area" instructions, but part of why
it's expensive on s390 is that they haven't implemented the
"user_access_begin()/end()' stuff. I think s390 could use that to at
least minimize some of the costs.
With the common case presumably being just a couple of words, it migth
not be worth it doing anything more than that even on s390.
Interestingly (or perhaps not) if I read the internal s390
implementation correctly, they kind of _have_ that concept and they
use it internally. It's just that they call it "enable_sacf_uaccess()"
and "disable_sacf_uaccess()" instead.
Linus