From 2fbb6773e3a6d5d18e84b0ac79b645147fbf0d66 Mon Sep 17 00:00:00 2001 From: Kyösti Mälkki Date: Tue, 15 May 2018 19:50:20 +0300 Subject: arch/x86: Enforce CPU stack alignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-on: https://review.coreboot.org/c/26302 Reviewed-by: Stefan Reinauer Reviewed-by: Aaron Durbin Tested-by: build bot (Jenkins) --- src/arch/x86/c_start.S | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/arch/x86/c_start.S') 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. */ -- cgit v1.2.3