[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH ARM v6 01/14] mini-os: x86_64: make thread stacks 16-byte aligned



On Wed, 2014-07-16 at 12:07 +0100, Thomas Leonard wrote:
> Otherwise, passing doubles to varargs functions causes a crash.
> 
> Signed-off-by: Thomas Leonard <talex5@xxxxxxxxx>

> +    /* Must ensure that (%rsp + 8) is 16-byte aligned at the start of 
> thread_starter. */

Is this really effectively a requirement for the stack to start out
misaligned? Or am I misinterpreting it?

Assuming I'm not reading it wrong is this some weird architectural quirk
which I've forgotten about or is it something to do with the behaviour
of thread_starter?

In either case, but especially the latter, I think it would be good to
explain more fully in the comment how this need arises.

...

So, reading the asm code it seems that x86_64 thread_starter will pop
2*quad words and push one, undoing the misalignment you've set up here.
A comment there pointing to this setup here would be good at a minimum,
but an even better fix would be to add a dummy push at that point
keeping both halves of this equation in the same place in that one
function making it responsible for maintaining the invariant.

Ian.


> +    thread->sp -= sizeof(unsigned long);
>      
>      stack_push(thread, (unsigned long) function);
>      stack_push(thread, (unsigned long) data);



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.