On Fri, Aug 18, 2017 at 02:48:31PM +1000, Michael Ellerman wrote: > Ram Pai <linux...@us.ibm.com> writes: > > On Fri, Aug 11, 2017 at 08:26:30PM +1000, Michael Ellerman wrote: > >> Thiago Jung Bauermann <bauer...@linux.vnet.ibm.com> writes: > >> > >> > Ram Pai <linux...@us.ibm.com> writes: > >> > > >> >> The value of the AMR register at the time of exception > >> >> is made available in gp_regs[PT_AMR] of the siginfo. > ... > >> > >> I don't understand why we are putting it in there at all? > >> > >> Is there some special handling of the actual register on signals? I > >> haven't seen it. In which case the process can get the value of AMR by > >> reading the register. ?? > > > > The value of AMR register at the time of the key-exception may not be > > the same when the signal handler is invoked. > > Why not?
Assume two threads of a task. T1: mprotect_key(foo, PAGE_SIZE, pkey=4); T1: set AMR to disable access for pkey 4; T1: key fault T2: set AMR to enable access to pkey 4; T1: fault handler called. This fault handler will see the new AMR and not the one at the time of the fault. RP