diff options
author | Raul E Rangel <rrangel@chromium.org> | 2021-07-22 12:25:35 -0600 |
---|---|---|
committer | Werner Zeh <werner.zeh@siemens.com> | 2021-07-26 04:40:29 +0000 |
commit | 9adf4a6656c609beec7a9ecd2615aade1ecf8caa (patch) | |
tree | 223024bd7cb8032a6b9bd93c2480c494e08efbb9 /src/lib | |
parent | 8c892070e94ca3131e0fe120544634877b8b133b (diff) |
lib/thread: Add asserts around stack size and alignment
`cpu_info()` requires that stacks be STACK_SIZE aligned and a power of 2.
BUG=b:179699789
TEST=Boot guybrush to the OS
Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Change-Id: I615623f05bfbe2861dcefe5cae66899aec306ba2
Reviewed-on: https://review.coreboot.org/c/coreboot/+/56530
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/thread.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lib/thread.c b/src/lib/thread.c index 3be2e92f5c..262cfa53bd 100644 --- a/src/lib/thread.c +++ b/src/lib/thread.c @@ -11,6 +11,10 @@ #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"); + static bool initialized; static void idle_thread_init(void); @@ -257,6 +261,9 @@ void threads_initialize(void) 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)); + /* Initialize the BSP thread first. The cpu_info structure is assumed * to be just under the top of the stack. */ t = &all_threads[0]; |