RISC-V: Round up pre-populated stack frame to arch stack alignment

The stack frame size, used for context switch, is rounded up to 16-bytes
alignment. Therefore, we need round down the pointer of top of the
pre-populated stack frame so that the preserved stack frame size is also
rounded up to 16-bytes alignment.

Fixes #29535

Signed-off-by: Shih-Wei Teng <swteng@andestech.com>
This commit is contained in:
Shih-Wei Teng 2021-01-06 14:50:21 +08:00 committed by Carles Cufí
commit d109805cb2

View file

@ -37,7 +37,9 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
#endif
/* Initial stack frame for thread */
stack_init = Z_STACK_PTR_TO_FRAME(struct __esf, stack_ptr);
stack_init = (struct __esf *)Z_STACK_PTR_ALIGN(
Z_STACK_PTR_TO_FRAME(struct __esf, stack_ptr)
);
/* Setup the initial stack frame */
stack_init->a0 = (ulong_t)entry;