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 AM, Masao Uebayashi 
<uebayasi%gmail.com@localhost> 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.

Actually, s/can/must/.  Otherwise signal SP is always aligned to
8-bytes, not 16-bytes.   Correct me if I'm wrong.


Home | Main Index | Thread Index | Old Index