From 2707ba58d29d0972aa09de3470f3bc447e2f1cf9 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Tue, 7 Jun 2022 06:43:28 +0800 Subject: [PATCH] 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 --- 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 33d65ac445d..a3f7be7b2c6 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 01804fefc4a..68b580a9321 100644 --- a/libs/libc/tls/tls_getinfo.c +++ b/libs/libc/tls/tls_getinfo.c @@ -30,7 +30,7 @@ #include #include -#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)) */