Port-amd64 archive

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

amd64 signal stack alignment



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