Re: i386 ABI and the stack

From: Linus Torvalds
Date: Fri Jun 23 2006 - 21:55:09 EST




On Fri, 23 Jun 2006, Albert Cahalan wrote:
>
> Exactly how is an access below %esp a bug if we just added support?

It's always a bug on x86.

Signal handlers will overwrite the stack, so if you use the stack before
decrementing the stack pointer, you're fundamentally screwed.

The "enter" (and "pusha" etc) instructions are special and magical,
because they _will_ decrement the stack pointer atomically if they
succeed.

> It seems that we're throwing away performance if we discourage
> the compiler from taking advantage of this area to optimize
> leaf functions and perhaps improve instruction scheduling.

We always have. It's the x86 ABI.

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.

Linus

(*) That "128 byte" is from memory. Maybe it's bigger.
-
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/