diff options
author | Raul E Rangel <rrangel@chromium.org> | 2021-09-24 14:00:56 -0600 |
---|---|---|
committer | Raul Rangel <rrangel@chromium.org> | 2021-10-05 22:40:25 +0000 |
commit | db16ac95789d5ecc736c586c261c5e87358b718b (patch) | |
tree | c4e7001875d43a8b2d1861bdaece3f46cca0d2dd | |
parent | 968f140ecbde7bbf71b6b71d392bb0db97ccf64e (diff) |
lib/thread: Remove thread stack alignment requirement
CPU_INFO_V2 now encapsulates the cpu_info requirements. They no longer
need to leak through to thread.c. This allows us to remove the alignment
requirement.
BUG=b:179699789
TEST=Reboot stress test guybrush 50 times.
Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Change-Id: I0af91feddcbd93b7f7d0f17009034bd1868d5aef
Reviewed-on: https://review.coreboot.org/c/coreboot/+/57928
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Eric Peers <epeers@google.com>
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
-rw-r--r-- | src/lib/thread.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/src/lib/thread.c b/src/lib/thread.c index ac8460c964..9008147eae 100644 --- a/src/lib/thread.c +++ b/src/lib/thread.c @@ -11,16 +11,7 @@ #include <thread.h> #include <timer.h> -/* Can't use the IS_POWER_OF_2 in _Static_assert */ -_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 u8 thread_stacks[CONFIG_STACK_SIZE * CONFIG_NUM_THREADS] __aligned(sizeof(uint64_t)); static bool initialized; static void idle_thread_init(void); @@ -90,6 +81,9 @@ static inline struct thread *get_free_thread(void) t = pop_thread(&free_threads); /* Reset the current stack value to the original. */ + if (!t->stack_orig) + die("%s: Invalid stack value\n", __func__); + t->stack_current = t->stack_orig; return t; @@ -250,15 +244,10 @@ static void threads_initialize(void) if (initialized) return; - /* `cpu_info()` requires the stacks to be STACK_SIZE aligned */ - assert(IS_ALIGNED((uintptr_t)thread_stacks, CONFIG_STACK_SIZE)); - - /* Initialize the BSP thread first. The cpu_info structure is assumed - * to be just under the top of the stack. */ t = &all_threads[0]; ci = cpu_info(); ci->thread = t; - t->stack_orig = (uintptr_t)ci; + t->stack_orig = (uintptr_t)NULL; /* We never free the main thread */ t->id = 0; t->can_yield = 1; |