On Wed, Feb 13, 2019 at 02:00:26PM +0000, Will Deacon wrote: > The difference is because getting preempted in the sequence above is > triggered off the back of an interrupt. On arm64, and I think also on x86, > the user access state (SMAP or PAN) is saved and restored across exceptions > but not across context switch.
A quick reading of the SDM seems to suggest the SMAP state is part of EFLAGS, which is context switched just fine AFAIK. SMAP {ab,re}uses the EFLAGS.AC bit. > Consequently, taking an irq in a > user_access_{begin,end} section and then scheduling is fine, but calling > schedule directly within such a section is not.