stack size limit on ppc/ppc64

Alan Modra amodra at
Wed Nov 5 22:08:59 EST 2003

On Wed, Nov 05, 2003 at 08:23:18PM +1100, Paul Mackerras wrote:
> Alan Modra writes:
> > ppc64 stack frames are required to be set up using stdu or stdux (set
> > back chain and update sp atomically), so I can't see that it's necessary
> > to check all the byte and word insns.
> And on ppc32 the ABI says that they are set up with stwu or stwux.
> The reason for allowing the other forms is that I was making the
> kernel enforce the rule "no accesses allowed between the top of the
> heap and the stack pointer" (actually some constant offset below the
> stack pointer),

I agree that this is a worthy aim.

> where the "stack pointer" is interpreted to mean the
> *final* stack pointer value for st*u[x] instructions.  I think it is
> more appropriate for the kernel to enforce that rule than for the
> kernel to require that programs follow the ELF ABI internally.

But I fail to see how allowing something like the following to
extend the stack helps meet that aim.

 lis 9,-10
 stbux 3,1,9

That stbux is just a wild write that also happens to fiddle with r1.
It's _not_ a valid stack frame allocation, which must store the old
value of r1, hence must use stwu or stwux (*) on ppc32 and stdu or stdux
on ppc64.  A byte or half-word write is just too small.

(*) I suppose you could construct a sequence to store the old r1
using a float reg, but it's stretching credibility to beleive that
anyone would actually try that!

Alan Modra
IBM OzLabs - Linux Technology Centre

** Sent via the linuxppc64-dev mail list. See

More information about the Linuxppc64-dev mailing list