Port-amd64 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: amd64 signal stack alignment



On Tue, May 13, 2014 at 10:15:07AM +0900, Masao Uebayashi wrote:
> On Tue, May 13, 2014 at 9:57 AM, Masao Uebayashi 
> <uebayasi%gmail.com@localhost> wrote:
> > sys/arch/amd64/amd64/machdep.c:
> >
> >  562         /* Allocate space for the signal handler context. */
> >  563         if (onstack)
> >  564                 sp = ((char *)l->l_sigstk.ss_sp + l->l_sigstk.ss_size);
> >  565         else
> >  566                 /* AMD64 ABI 128-bytes "red zone". */
> >  567                 sp = (char *)tf->tf_rsp - 128;
> >  568
> >  569         sp -= sizeof(struct sigframe_siginfo);
> >  570         /* Round down the stackpointer to a multiple of 16 for the 
> > ABI. */
> >  571         fp = (struct sigframe_siginfo *)(((unsigned long)sp & ~15) - 
> > 8);
> >
> > These calculation is very unclear to me.  IIUC:
> >
> > - 8-bytes fxsave is saved below "red zone" with 8-bytes alignment, and
> 
> fxsave saved on stack was not part of ABI but just an implementation.
> Now it's no longer on stack but in pcb, right?  If yes the "- 8" can
> go away.

The on-stack fxsave structure is a parameter to the signal handler.
It is copied from, and restored to, the one in the pcb so that the signal
handler can see and modify all the process registers.

The signal handler itself gets a clean FP state.

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index