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 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.

> - sigframe_siginfo is written below fxsave (above initial signal SP)
> - Initial signal SP is 16-bytes aligned
>
> FreeBSD/amd64 sendsig() is much clearer.


Home | Main Index | Thread Index | Old Index