diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2018-05-15 19:50:20 +0300 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2019-01-14 11:59:51 +0000 |
commit | 2fbb6773e3a6d5d18e84b0ac79b645147fbf0d66 (patch) | |
tree | a4c35e5e6167ea80573ec379585725d919a90b51 /src/arch/x86 | |
parent | b318be22183ca4c306203479b4410ab6365235aa (diff) |
arch/x86: Enforce CPU stack alignment
When rmodule is loaded CPU stack alignment is only guaranteed
to 4kiB. Implementation of cpu_info() requires that each
CPU sees its stack aligned to CONFIG_STACK_SIZE.
Add one spare CPU for the stack reserve, such that alignment can
be enforced runtime.
Change-Id: Ie04956c64df0dc7bb156002d3d4f2629f92b340e
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/26302
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/arch/x86')
-rw-r--r-- | src/arch/x86/c_start.S | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/arch/x86/c_start.S b/src/arch/x86/c_start.S index 3fbdac11b3..86147ecdc7 100644 --- a/src/arch/x86/c_start.S +++ b/src/arch/x86/c_start.S @@ -19,9 +19,11 @@ .global _stack .global _estack +/* Stack alignment is not enforced with rmodule loader, reserve one + * extra CPU such that alignment can be enforced on entry. */ .align CONFIG_STACK_SIZE _stack: -.space CONFIG_MAX_CPUS*CONFIG_STACK_SIZE +.space (CONFIG_MAX_CPUS+1)*CONFIG_STACK_SIZE _estack: #if IS_ENABLED(CONFIG_COOP_MULTITASKING) .global thread_stacks @@ -70,8 +72,9 @@ _start: rep stosl - /* set new stack */ + /* Set new stack with enforced alignment. */ movl $_estack, %esp + andl $(~(CONFIG_STACK_SIZE-1)), %esp #if IS_ENABLED(CONFIG_COOP_MULTITASKING) /* Push the thread pointer. */ |