mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 03:05:40 +08:00
arch: fix alignment bug for archs that need stack alignment
These archs only align the size of the stack, forgeting to do the stack start addr alignment, this patch fixes it. Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
This commit is contained in:
committed by
Alan C. Assis
parent
bd28635b68
commit
b92e0b6730
@@ -85,27 +85,11 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
|
||||
/* Save the new stack allocation */
|
||||
|
||||
tcb->stack_alloc_ptr = stack;
|
||||
tcb->stack_base_ptr = (void *)STACK_ALIGN_UP((uintptr_t)stack);
|
||||
|
||||
/* sparc uses a push-down stack: the stack grows toward loweraddresses in
|
||||
* memory. The stack pointer register, points to the lowest, valid work
|
||||
* address (the "top" of the stack). Items on the stack are referenced
|
||||
* as positive word offsets from sp.
|
||||
*/
|
||||
|
||||
top_of_stack = (uint32_t)tcb->stack_alloc_ptr + stack_size;
|
||||
|
||||
/* The sparc stack must be aligned at word (4 byte) or double word (8 byte)
|
||||
* boundaries. If necessary top_of_stack must be rounded down to the
|
||||
* next boundary
|
||||
*/
|
||||
|
||||
top_of_stack = STACK_ALIGN_DOWN(top_of_stack);
|
||||
size_of_stack = top_of_stack - (uint32_t)tcb->stack_alloc_ptr;
|
||||
|
||||
/* Save the adjusted stack values in the struct tcb_s */
|
||||
|
||||
tcb->stack_base_ptr = tcb->stack_alloc_ptr;
|
||||
tcb->adj_stack_size = size_of_stack;
|
||||
top_of_stack = STACK_ALIGN_DOWN((uintptr_t)stack + stack_size);
|
||||
size_of_stack = top_of_stack - (uintptr_t)tcb->stack_base_ptr;
|
||||
tcb->adj_stack_size = size_of_stack;
|
||||
|
||||
#ifdef CONFIG_STACK_COLORATION
|
||||
/* If stack debug is enabled, then fill the stack with a
|
||||
|
||||
Reference in New Issue
Block a user