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/cpu/x86/mp_init.c | |
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/cpu/x86/mp_init.c')
-rw-r--r-- | src/cpu/x86/mp_init.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c index 9526824976..3889c7d28e 100644 --- a/src/cpu/x86/mp_init.c +++ b/src/cpu/x86/mp_init.c @@ -18,6 +18,7 @@ #include <stdint.h> #include <rmodule.h> #include <arch/cpu.h> +#include <commonlib/helpers.h> #include <cpu/cpu.h> #include <cpu/intel/microcode.h> #include <cpu/x86/cache.h> @@ -229,11 +230,11 @@ static void asmlinkage ap_init(unsigned int cpu) static void setup_default_sipi_vector_params(struct sipi_params *sp) { - sp->gdt = (uint32_t)&gdt; - sp->gdtlimit = (uint32_t)&gdt_end - (u32)&gdt - 1; - sp->idt_ptr = (uint32_t)&idtarg; + sp->gdt = (uintptr_t)&gdt; + sp->gdtlimit = (uintptr_t)&gdt_end - (uintptr_t)&gdt - 1; + sp->idt_ptr = (uintptr_t)&idtarg; sp->stack_size = CONFIG_STACK_SIZE; - sp->stack_top = (uint32_t)&_estack; + sp->stack_top = ALIGN_DOWN((uintptr_t)&_estack, CONFIG_STACK_SIZE); /* Adjust the stack top to take into account cpu_info. */ sp->stack_top -= sizeof(struct cpu_info); } |