You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/02/19 03:05:21 UTC

[incubator-nuttx] branch master updated (7750de7 -> f344e7b)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from 7750de7  stdint.h: Use conversion macros for the definition of MIN and MAX constants
     new e87d147  arch: xtensa: Fix stack coloring
     new f344e7b  boards: esp32-devkitc: Add CONFIG_STACK_COLORATION=y to wapi_smp/defconfig

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/xtensa/src/common/xtensa_checkstack.c         | 12 ++++++++--
 arch/xtensa/src/common/xtensa_createstack.c        | 27 ++++++++++++++--------
 .../esp32/esp32-devkitc/configs/wapi_smp/defconfig |  1 +
 3 files changed, 29 insertions(+), 11 deletions(-)


[incubator-nuttx] 02/02: boards: esp32-devkitc: Add CONFIG_STACK_COLORATION=y to wapi_smp/defconfig

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit f344e7b5bf234c2134dff00d9ebc8a6f1ff9ec43
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Fri Feb 19 08:37:11 2021 +0900

    boards: esp32-devkitc: Add CONFIG_STACK_COLORATION=y to wapi_smp/defconfig
    
    Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
 boards/xtensa/esp32/esp32-devkitc/configs/wapi_smp/defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/wapi_smp/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/wapi_smp/defconfig
index 3b23021..37e67a1 100644
--- a/boards/xtensa/esp32/esp32-devkitc/configs/wapi_smp/defconfig
+++ b/boards/xtensa/esp32/esp32-devkitc/configs/wapi_smp/defconfig
@@ -78,6 +78,7 @@ CONFIG_SMP=y
 CONFIG_SMP_NCPUS=2
 CONFIG_SPI=y
 CONFIG_SPIFFS_NAME_MAX=48
+CONFIG_STACK_COLORATION=y
 CONFIG_START_DAY=18
 CONFIG_START_MONTH=2
 CONFIG_START_YEAR=2021


[incubator-nuttx] 01/02: arch: xtensa: Fix stack coloring

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit e87d14721ef11546b068e4d78a0bd7c1005ba83e
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Fri Feb 19 08:26:13 2021 +0900

    arch: xtensa: Fix stack coloring
    
    Summary:
    - Call up_stack_color() correctly in the up_create_stack()
    - Fix nwords calculation in up_stack_color()
    - Also, refactor up_stack_color()
    - Fix do_stackcheck() to consider stack alignment
    
    Impact:
    - Only for CONFIG_STACK_COLORATION=y
    
    Testing:
    - Tested with esp32-devkitc:wapi_smp
    
    Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
 arch/xtensa/src/common/xtensa_checkstack.c  | 12 ++++++++++--
 arch/xtensa/src/common/xtensa_createstack.c | 27 ++++++++++++++++++---------
 2 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/arch/xtensa/src/common/xtensa_checkstack.c b/arch/xtensa/src/common/xtensa_checkstack.c
index 6728309..b666b33 100644
--- a/arch/xtensa/src/common/xtensa_checkstack.c
+++ b/arch/xtensa/src/common/xtensa_checkstack.c
@@ -55,6 +55,14 @@
 
 #ifdef CONFIG_STACK_COLORATION
 
+#define STACK_ALIGNMENT     16
+
+/* Stack alignment macros */
+
+#define STACK_ALIGN_MASK    (STACK_ALIGNMENT - 1)
+#define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK)
+#define STACK_ALIGN_UP(a)   (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK)
+
 /****************************************************************************
  * Private Function Prototypes
  ****************************************************************************/
@@ -97,8 +105,8 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
 #ifdef CONFIG_TLS_ALIGNED
   DEBUGASSERT((alloc & TLS_STACK_MASK) == 0);
 #endif
-  start = alloc + sizeof(struct tls_info_s);
-  end   = (alloc + size + 15) & ~15;
+  start = STACK_ALIGN_UP(alloc + sizeof(struct tls_info_s));
+  end   = STACK_ALIGN_DOWN(alloc + size);
 
   /* 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 92fec43..19a6cbd 100644
--- a/arch/xtensa/src/common/xtensa_createstack.c
+++ b/arch/xtensa/src/common/xtensa_createstack.c
@@ -269,10 +269,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
 
       memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s));
 
-      board_autoled_on(LED_STACKCREATED);
-      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
@@ -284,6 +280,10 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
                      tcb->adj_stack_size - sizeof(struct tls_info_s));
 #endif
 
+      board_autoled_on(LED_STACKCREATED);
+      return OK;
+    }
+
   return ERROR;
 }
 
@@ -298,17 +298,26 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
 #ifdef CONFIG_STACK_COLORATION
 void up_stack_color(FAR void *stackbase, size_t nbytes)
 {
-  /* Take extra care that we do not write outsize the stack boundaries */
+  uintptr_t start;
+  uintptr_t end;
+  size_t nwords;
+  FAR uint32_t *ptr;
+
+  /* Take extra care that we do not write outside the stack boundaries */
+
+  start = STACK_ALIGN_UP((uintptr_t)stackbase);
+  end   = STACK_ALIGN_DOWN((uintptr_t)stackbase + nbytes);
+
+  /* Get the adjusted size based on the top and bottom of the stack */
 
-  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;
+  nwords = (end - start) >> 2;
+  ptr  = (FAR uint32_t *)start;
 
   /* Set the entire stack to the coloration value */
 
   while (nwords-- > 0)
     {
-      *stkptr++ = STACK_COLOR;
+      *ptr++ = STACK_COLOR;
     }
 }
 #endif