From f5a449487c93f4b3607c005b8d629f62713e2fc6 Mon Sep 17 00:00:00 2001 From: p-szafonimateusz Date: Thu, 26 Sep 2024 13:58:54 +0200 Subject: [PATCH] arch/intel64: colorize IDLE stack for AP cores colorize IDLE stack for AP cores in x86_64 Signed-off-by: p-szafonimateusz --- arch/x86_64/src/intel64/intel64_cpustart.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/x86_64/src/intel64/intel64_cpustart.c b/arch/x86_64/src/intel64/intel64_cpustart.c index 2fe404349a..7a71125527 100644 --- a/arch/x86_64/src/intel64/intel64_cpustart.c +++ b/arch/x86_64/src/intel64/intel64_cpustart.c @@ -32,6 +32,7 @@ #include #include +#include "sched/sched.h" #include "init/init.h" #include "intel64_lowsetup.h" @@ -128,8 +129,11 @@ static int x86_64_ap_startup(int cpu) void x86_64_ap_boot(void) { + struct tcb_s *tcb = this_task(); uint8_t cpu = 0; + UNUSED(tcb); + /* Do some checking on CPU compatibilities at the top of this function */ x86_64_check_and_enable_capability(); @@ -153,7 +157,7 @@ void x86_64_ap_boot(void) #ifdef CONFIG_SCHED_INSTRUMENTATION /* Notify that this CPU has started */ - sched_note_cpu_started(this_task()); + sched_note_cpu_started(tcb); #endif sinfo("cpu=%d\n", cpu); @@ -165,6 +169,15 @@ void x86_64_ap_boot(void) up_enable_irq(SMP_IPI_IRQ); up_enable_irq(SMP_IPI_ASYNC_IRQ); +#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. + */ + + x86_64_stack_color(tcb->stack_alloc_ptr, 0); +#endif + /* CPU ready */ x86_64_cpu_ready_set(cpu);