arch/xtensa: Fix alignement when coloring and checking the stacks.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
This commit is contained in:
Abdelatif Guettouche 2020-12-02 16:15:51 +00:00 committed by Alan Carvalho de Assis
parent 7075c98978
commit 5d7428a385
2 changed files with 14 additions and 14 deletions

View File

@ -98,7 +98,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
DEBUGASSERT((alloc & TLS_STACK_MASK) == 0);
#endif
start = alloc + sizeof(struct tls_info_s);
end = (alloc + size + 3) & ~3;
end = (alloc + size + 15) & ~15;
/* Get the adjusted size based on the top and bottom of the stack */

View File

@ -217,17 +217,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
uintptr_t top_of_stack;
size_t size_of_stack;
#ifdef CONFIG_STACK_COLORATION
/* If stack debug is enabled, then fill the stack with a
* recognizable value that we can use later to test for high
* water marks.
*/
up_stack_color((FAR void *)tcb->stack_alloc_ptr +
sizeof(struct tls_info_s),
stack_size - sizeof(struct tls_info_s));
#endif
/* XTENSA uses a push-down stack: the stack grows toward lower
* addresses in memory. The stack pointer register points to the
* lowest, valid working address (the "top" of the stack). Items on
@ -284,6 +273,17 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
return OK;
}
#ifdef CONFIG_STACK_COLORATION
/* If stack debug is enabled, then fill the stack with a
* recognizable value that we can use later to test for high
* water marks.
*/
up_stack_color((FAR void *)tcb->stack_alloc_ptr +
sizeof(struct tls_info_s),
tcb->adj_stack_size - sizeof(struct tls_info_s));
#endif
return ERROR;
}
@ -300,8 +300,8 @@ void up_stack_color(FAR void *stackbase, size_t nbytes)
{
/* Take extra care that we do not write outsize the stack boundaries */
uint32_t *stkptr = (uint32_t *)(((uintptr_t)stackbase + 3) & ~3);
uintptr_t stkend = (((uintptr_t)stackbase + nbytes) & ~3);
uint32_t *stkptr = (uint32_t *)(((uintptr_t)stackbase + 15) & ~15);
uintptr_t stkend = (((uintptr_t)stackbase + nbytes) & ~15);
size_t nwords = (stkend - (uintptr_t)stackbase) >> 2;
/* Set the entire stack to the coloration value */