[RFC v7 24/25] powerpc: Deliver SEGV signal on pkey violation

Ram Pai linuxram at us.ibm.com
Sat Aug 19 08:49:57 AEST 2017


On Fri, Aug 18, 2017 at 10:04:10AM -0700, Ram Pai wrote:
> On Fri, Aug 18, 2017 at 02:48:31PM +1000, Michael Ellerman wrote:
> > Ram Pai <linuxram at us.ibm.com> writes:
> > > On Fri, Aug 11, 2017 at 08:26:30PM +1000, Michael Ellerman wrote:
> > >> Thiago Jung Bauermann <bauerman at linux.vnet.ibm.com> writes:
> > >> 
> > >> > Ram Pai <linuxram at 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.

Ok. Ben debunked my above reason. So at this point I dont have a solid
reason to defend my statement --
"The value of AMR register at the time of the key-exception may not be
the same when the signal handler is invoked."

Coming back to the your main question, "why we need to provide the
contents of AMR register to the signal handler?" --   the only reason
i can see is, probably tools like gdb and ptrace may find it useful.

And since it was suggested that content of IAMR is also useful to the
application, the value of which cannot be accessed from userspace,
it may make sense to provide both the contents.

Please suggest.
RP



More information about the Linuxppc-dev mailing list