]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Correctly align the stack. The early csu assumed we passed the aux vector
authorandrew <andrew@FreeBSD.org>
Sun, 18 Oct 2015 13:23:21 +0000 (13:23 +0000)
committerandrew <andrew@FreeBSD.org>
Sun, 18 Oct 2015 13:23:21 +0000 (13:23 +0000)
in through the stack pointer, however this may have been misaligned
causing some userland applications to crash. A workaround was committed in
r284707 where userland would check if the aux vector was passed using the
old or new ABI and adjust the stack if needed. As 4 months have passed it
is time to move to the new ABI, with the expectation the compat code in csu
and the runtime linker to be removed in the future.

Sponsored by: ABT Systems Ltd

sys/arm64/arm64/machdep.c

index 4bb3f674b9f427d303e32e90c49fe8db4b8cab34..e92a99ff3057a40328e95fe8cf0e493b9c0cd104 100644 (file)
@@ -251,7 +251,13 @@ exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
 
        memset(tf, 0, sizeof(struct trapframe));
 
-       tf->tf_sp = stack;
+       /*
+        * We need to set x0 for init as it doesn't call
+        * cpu_set_syscall_retval to copy the value. We also
+        * need to set td_retval for the cases where we do.
+        */
+       tf->tf_x[0] = td->td_retval[0] = stack;
+       tf->tf_sp = STACKALIGN(stack);
        tf->tf_lr = imgp->entry_addr;
        tf->tf_elr = imgp->entry_addr;
 }