zephyr/arch
Andy Ross cce5ff1510 arch/x86: Fix stack alignment for user threads
The x86_64 SysV ABI requires 16 byte alignment for the stack pointer
during execution of normal code.  That means that on entry to an
ABI-compatible C function (which is reached via a CALL instruction
that pushes the return address) the RSP register must be MISaligned by
exactly 8 bytes.  The kernel mode thread setup got this right, but we
missed the equivalent condition in userspace entry.

The end result was a misaligned stack, which is surprisingly robust
for most use.  But recent toolchains have starting doing some more
elaborate vectorization, and the resulting SSE instructions started
failing in userspace on the misaliged loads.

Note that there's a comment about optimization: we're doing the stack
alignment in the "wrong place" and are needlessly wasting bytes in
some cases.  We should see the raw stack boundaries where we are
setting up RSP values.  Add a FIXME to this effect, but don't touch
anything as this patch is a targeted bugfix.

Also fix a somewhat embarassing 32-bit-ism that would have truncated
the address of a userspace stack that we tried to put above 4G.

Fixes #31018

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-02-03 18:45:48 -05:00
..
arc linker: remove asterisk from IRQ/ISR section name macro 2021-01-26 16:24:11 -05:00
arm arm: cortex_m: fix vector table relocation in non-XIP builds 2021-02-03 10:44:17 -05:00
common gen_isr_tables: Added check of the IRQ num before accessing the vt 2021-01-24 10:12:54 -05:00
nios2 kernel: Cleanup logger setup in kernel files 2020-11-27 09:56:34 -05:00
posix posix: Add cpu_hold() function to better emulate code delay 2020-12-14 12:32:11 +01:00
riscv arch/riscv: boost default stacks 2021-01-15 13:06:33 -05:00
sparc lib/os/heap: introduce option to force big heap mode 2021-01-24 10:11:11 -05:00
x86 arch/x86: Fix stack alignment for user threads 2021-02-03 18:45:48 -05:00
xtensa arch: xtensa: Print backtrace from panic handler 2021-01-23 08:43:10 -05:00
CMakeLists.txt cmake: fix include directories to work with out-of-tree arch 2020-08-05 08:06:07 -04:00
Kconfig arm: cortex_m: select by default FP sharing mode when using the FPU 2021-02-02 17:58:58 -05:00