You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2022/06/07 23:56:09 UTC

[incubator-nuttx] branch master updated: sched/tls: Shouldn't get tls info directly from sp in kernel space

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 2707ba58d2 sched/tls: Shouldn't get tls info directly from sp in kernel space
2707ba58d2 is described below

commit 2707ba58d29d0972aa09de3470f3bc447e2f1cf9
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue Jun 7 06:43:28 2022 +0800

    sched/tls: Shouldn't get tls info directly from sp in kernel space
    
    since the stack may switch to the kernel or interrupt stack
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 include/nuttx/tls.h         | 2 +-
 libs/libc/tls/tls_getinfo.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/nuttx/tls.h b/include/nuttx/tls.h
index 33d65ac445..a3f7be7b2c 100644
--- a/include/nuttx/tls.h
+++ b/include/nuttx/tls.h
@@ -304,7 +304,7 @@ uintptr_t task_tls_get_value(int tlsindex);
 
 #if defined(up_tls_info)
 #  define tls_get_info() up_tls_info()
-#elif defined(CONFIG_TLS_ALIGNED)
+#elif defined(CONFIG_TLS_ALIGNED) && !defined(__KERNEL__)
 #  define tls_get_info() TLS_INFO(up_getsp())
 #else
 FAR struct tls_info_s *tls_get_info(void);
diff --git a/libs/libc/tls/tls_getinfo.c b/libs/libc/tls/tls_getinfo.c
index 01804fefc4..68b580a932 100644
--- a/libs/libc/tls/tls_getinfo.c
+++ b/libs/libc/tls/tls_getinfo.c
@@ -30,7 +30,7 @@
 #include <nuttx/arch.h>
 #include <nuttx/tls.h>
 
-#if !defined(up_tls_info) && !defined(CONFIG_TLS_ALIGNED)
+#if !defined(up_tls_info) && (defined(__KERNEL__) || !defined(CONFIG_TLS_ALIGNED))
 
 /****************************************************************************
  * Public Functions
@@ -72,4 +72,4 @@ FAR struct tls_info_s *tls_get_info(void)
   return info;
 }
 
-#endif /* !defined(up_tls_info) && !defined(CONFIG_TLS_ALIGNED) */
+#endif /* !defined(up_tls_info) && (defined(__KERNEL__) || !defined(CONFIG_TLS_ALIGNED)) */