From 5cde8c693457bd1683a64bf1e0324a37e99c6449 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Mon, 14 Feb 2022 18:17:49 +0800 Subject: [PATCH] risc-v: Let g_cpu_basestack determined at compile time Fix the CPU1 idle tasks stack corruption since the cpux's idle stack is loaded from g_cpu_basestack (data section) before, but on this time it maybe not ready since it is initialized by CPU0, and the value from g_cpu_basestack is random. Signed-off-by: Huang Qi --- arch/risc-v/src/common/riscv_cpuidlestack.c | 2 +- arch/risc-v/src/common/riscv_internal.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/risc-v/src/common/riscv_cpuidlestack.c b/arch/risc-v/src/common/riscv_cpuidlestack.c index 00750d496f..3b2227daf1 100644 --- a/arch/risc-v/src/common/riscv_cpuidlestack.c +++ b/arch/risc-v/src/common/riscv_cpuidlestack.c @@ -83,7 +83,7 @@ static uint8_t aligned_data(16) cpu7_idlestack[CONFIG_IDLETHREAD_STACKSIZE]; * Public Data ****************************************************************************/ -uint8_t *g_cpu_basestack[CONFIG_SMP_NCPUS] = +const uint8_t * const g_cpu_basestack[CONFIG_SMP_NCPUS] = { (uint8_t *)&_ebss, #if CONFIG_SMP_NCPUS > 1 diff --git a/arch/risc-v/src/common/riscv_internal.h b/arch/risc-v/src/common/riscv_internal.h index 160ccb4dd7..e677516039 100644 --- a/arch/risc-v/src/common/riscv_internal.h +++ b/arch/risc-v/src/common/riscv_internal.h @@ -117,7 +117,7 @@ EXTERN uintptr_t g_idle_topstack; /* Address of per-cpu idle stack base */ -EXTERN uint8_t *g_cpu_basestack[CONFIG_SMP_NCPUS]; +EXTERN const uint8_t * const g_cpu_basestack[CONFIG_SMP_NCPUS]; /* Address of the saved user stack pointer */