Thread (48 messages) 48 messages, 6 authors, 2017-01-13

Re: x86-64: Maintain 16-byte stack alignment

From: Andy Lutomirski <luto@amacapital.net>
Date: 2017-01-11 06:01:46
Also in: lkml

On Tue, Jan 10, 2017 at 8:35 PM, Herbert Xu [off-list ref] wrote:
On Tue, Jan 10, 2017 at 08:17:17PM -0800, Linus Torvalds wrote:
quoted
That said, I do think that the "don't assume stack alignment, do it by
hand" may be the safer thing. Because who knows what the random rules
will be on other architectures.
Sure we can ban the use of attribute aligned on stacks.  But
what about indirect uses through structures?  For example, if
someone does

struct foo {
} __attribute__ ((__aligned__(16)));

int bar(...)
{
        struct foo f;

        return baz(&f);
}

then baz will end up with an unaligned argument.  The worst part
is that it is not at all obvious to the person writing the function
bar.
Linus, I'm starting to lean toward agreeing with Herbert here, except
that we should consider making it conditional on having a silly GCC
version.  After all, the silly GCC versions are wasting space and time
with alignment instructions no matter what we do, so this would just
mean tweaking the asm and adding some kind of check_stack_alignment()
helper to throw out a WARN_ONCE() if we miss one.  The problem with
making it conditional is that making pt_regs effectively live at a
variable offset from %rsp is just nasty.

--Andy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help