On Wed, Feb 20, 2019 at 02:55:59PM -0800, H. Peter Anvin wrote: > On 2/19/19 4:48 AM, Will Deacon wrote: > > > > I think you'll still hate this, but could we not disable preemption during > > the uaccess-enabled region, re-enabling it on the fault path after we've > > toggled uaccess off and disable it again when we return back to the > > uaccess-enabled region? Doesn't help with tracing, but it should at least > > handle the common case. > > > > There is a worse problem with this, I still realize: this would mean blocking > preemption across what could possibly be a *very* large copy_from_user(), for > example.
I don't think it's legitimate to call copy_{to,from}_user() inside a user_access_{begin,end} region. You'd need to add some unsafe variants, which could periodically disable uaccess and call cond_resched() inside the loop to avoid the problem you're eluding to. For existing callers of copy_{to,from}_user(), there's no issue as they don't call into the scheduler during the copy operation. Exceptions are handled fine by the code in mainline today. GCC plugins are a cool idea, but I'm just a bit nervous about relying on them for things like this. Will