lib/thread,arch/x86: Move thread stacks into C bss

There is no reason this needs to be done in asm. It also allows
different stages to use threads. If threads are no used in a specific
stage, the compiler will garbage collect the space.

BUG=b:179699789
TEST=Boot guybrush to the OS

Suggested-by: Julius Werner <jwerner@chromium.org>
Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Change-Id: Ib5a84a62fdc75db8ef0358ae16ff69c20cbafd5f
Reviewed-on: https://review.coreboot.org/c/coreboot/+/56531
Reviewed-by: Furquan Shaikh <furquan@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Raul E Rangel
2021-07-22 12:37:23 -06:00
committed by Patrick Georgi
parent b9d94ecd78
commit 7db7ee984c
4 changed files with 6 additions and 20 deletions

View File

@ -15,6 +15,12 @@
_Static_assert((CONFIG_STACK_SIZE & (CONFIG_STACK_SIZE - 1)) == 0,
"`cpu_info()` requires the stack size to be a power of 2");
/*
* struct cpu_info lives at the top of each thread's stack. `cpu_info()` locates this struct by
* taking the current stack pointer and masking off CONFIG_STACK_SIZE. This requires the stack
* to be STACK_SIZE aligned.
*/
static u8 thread_stacks[CONFIG_STACK_SIZE * CONFIG_NUM_THREADS] __aligned(CONFIG_STACK_SIZE);
static bool initialized;
static void idle_thread_init(void);
@ -257,9 +263,6 @@ void threads_initialize(void)
struct thread *t;
u8 *stack_top;
struct cpu_info *ci;
u8 *thread_stacks;
thread_stacks = arch_get_thread_stackbase();
/* `cpu_info()` requires the stacks to be STACK_SIZE aligned */
assert(IS_ALIGNED((uintptr_t)thread_stacks, CONFIG_STACK_SIZE));