Re: user_access_{save,restore}() semantics

From: Christoph Hellwig
Date: Fri Jul 10 2020 - 12:46:30 EST


On Fri, Jul 10, 2020 at 06:40:37PM +0200, Peter Zijlstra wrote:
> On Fri, Jul 10, 2020 at 06:15:27PM +0200, Christoph Hellwig wrote:
> > Hi Peter,
> >
> > can you explain (and maybe document while we're at it) what the
> > exact semantics of the user_access_{save,restore} helpers are?
> >
> > Reverse engineering from the commit text they seem to be about
> > saving the current uaccess state. But do they also enable/disable
> > anything?
>
> user_access_save() is like local_irq_save(), it stores the EFLAGS and
> clears AC/IF resp. user_access_restore(), like local_irq_restore(),
> simply restores the previously saved EFLAGS.
>
> So for code that had user_access_begin(),
> user_access_save()/user_access_restore() will temporarily disable
> user-access and allow calling other code.
>
> something like so?

Looks good, thanks!