This is an automated email from the ASF dual-hosted git repository.
GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new b90f424a207 arch/arm64: preserve secondary IDLE TLS during stack
coloration
b90f424a207 is described below
commit b90f424a2079f1d35e29f0fee274307baa073e35
Author: hujun5 <[email protected]>
AuthorDate: Wed Nov 25 17:16:46 2026 +0800
arch/arm64: preserve secondary IDLE TLS during stack coloration
The assembly startup colored the entire secondary IDLE stack after TLS
initialization and overwrote the TLS data stored at the stack bottom.
Color only the active stack range from stack_base_ptr during C startup,
and remove the full-stack coloring loop from the assembly path.
Signed-off-by: hujun5 <[email protected]>
---
arch/arm64/src/common/arm64_cpustart.c | 10 ++++++++++
arch/arm64/src/common/arm64_head.S | 17 ++++-------------
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/arch/arm64/src/common/arm64_cpustart.c
b/arch/arm64/src/common/arm64_cpustart.c
index 11f5f58df49..848f7cc522a 100644
--- a/arch/arm64/src/common/arm64_cpustart.c
+++ b/arch/arm64/src/common/arm64_cpustart.c
@@ -130,6 +130,16 @@ static void arm64_smp_init_top(void)
{
struct tcb_s *tcb = current_task(this_cpu());
+#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.
+ */
+
+ arm64_stack_color(tcb->stack_base_ptr, 0);
+#endif /* CONFIG_STACK_COLORATION */
+
#ifndef CONFIG_SUPPRESS_INTERRUPTS
/* And finally, enable interrupts */
diff --git a/arch/arm64/src/common/arm64_head.S
b/arch/arm64/src/common/arm64_head.S
index 2ed79756be0..a02ed9125f5 100644
--- a/arch/arm64/src/common/arm64_head.S
+++ b/arch/arm64/src/common/arm64_head.S
@@ -164,22 +164,13 @@ real_start:
cmp x1, #0
bne 1b
-# ifdef CONFIG_STACK_COLORATION
- /* Write a known value to the IDLE thread stack to support stack
- * monitoring logic
+ /* The IDLE thread stack is colored by up_cpu_idlestack() on CPU0 before
+ * tls_init_info() carves the TLS region out of its bottom. Re-coloring
+ * the whole stack here would overwrite that TLS info, so just advance
+ * x24 to the stack top.
*/
- ldr w1, =SMP_STACK_WORDS
- ldr w2, =STACK_COLOR
-
-.loop:
- sub w1, w1, #1
- str w2, [x24], #4
- cmp w1, #0
- bne .loop
-# else
add x24, x24, #(SMP_STACK_SIZE)
-# endif
/* Initialize percpu reg tpidr_el1 */