Re: i386 ABI and the stack

From: Linus Torvalds
Date: Fri Jun 23 2006 - 22:10:18 EST




On Fri, 23 Jun 2006, H. Peter Anvin wrote:
> >
> > The x86-64 ABI has a 128-byte(*) zone that is safe from signals etc, so you
> > can use a small amount of stack below the stackpointer safely. Not so on
> > x86.
>
> Adding a small redzone like this to i386 would be easy, though -- just drop
> the stack pointer by that much when creating a signal frame. 128 bytes isn't
> enough to interfere with libraries.

However, any binaries created with that in mind would be
buggy-by-definition on older kernels, so I don't think it's worth it.

> Unlike other enhancements that have been proposed to the i386 ABI (like
> regparm), this has the advantage of being fully backwards-compatible with old
> binaries and libraries.

Right, but it's not backwards-compatible with old kernels ;(

So any user space app that does it would have to be pretty crazy.

I don't think it's a huge advantage anyway. x86 CPU's are really good at
tracking %esp - there are papers out there that talk about how %esp is the
limiter for effective IPC, but modern x86 CPU's will generally have ways
around it, so in _practice_ I think you can do

subl $16,%esp
movl %eax,4(%esp)

without having any address stall on the subtract on most modern CPU cores
(because the core will break the dependency and track %esp specially).

That's the Yonah "stack engine", afaik. And I could obviously name other
CPU's that does it too, but I probably shouldn't ;)

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/