You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/12/09 12:44:23 UTC
[incubator-nuttx] 06/06: arch/xtensa: Fix alignement when coloring
and checking the stacks.
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 5d7428a38561af8e02b5c3168c93de113b69e50b
Author: Abdelatif Guettouche <ab...@espressif.com>
AuthorDate: Wed Dec 2 16:15:51 2020 +0000
arch/xtensa: Fix alignement when coloring and checking the stacks.
Signed-off-by: Abdelatif Guettouche <ab...@espressif.com>
---
arch/xtensa/src/common/xtensa_checkstack.c | 2 +-
arch/xtensa/src/common/xtensa_createstack.c | 26 +++++++++++++-------------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/arch/xtensa/src/common/xtensa_checkstack.c b/arch/xtensa/src/common/xtensa_checkstack.c
index 6eb8375..6728309 100644
--- a/arch/xtensa/src/common/xtensa_checkstack.c
+++ b/arch/xtensa/src/common/xtensa_checkstack.c
@@ -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 */
diff --git a/arch/xtensa/src/common/xtensa_createstack.c b/arch/xtensa/src/common/xtensa_createstack.c
index 8d39529..92fec43 100644
--- a/arch/xtensa/src/common/xtensa_createstack.c
+++ b/arch/xtensa/src/common/xtensa_createstack.c
@@ -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 */