Raul Rangel has submitted this change. ( https://review.coreboot.org/c/coreboot/+/57928 )
Change subject: lib/thread: Remove thread stack alignment requirement ......................................................................
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 --- M src/lib/thread.c 1 file changed, 5 insertions(+), 16 deletions(-)
Approvals: build bot (Jenkins): Verified Karthik Ramasubramanian: Looks good to me, approved Eric Peers: Looks good to me, but someone else must approve
diff --git a/src/lib/thread.c b/src/lib/thread.c index ac8460c..9008147e 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 @@ 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 @@ 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;