risc-v/k210: Move wfi to entry of the slave cpu boot routine

Fix another potential bug in non-smp case: load a value from overflowed address of g_cpu_basestack.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi 2022-02-14 16:34:18 +08:00 committed by Masayuki Ishikawa
parent 0258968abd
commit 0d7f30c86d
1 changed files with 7 additions and 5 deletions

View File

@ -53,6 +53,13 @@ __start:
j 2f
1:
/* In case of single CPU config, stop here */
#if !defined(CONFIG_SMP) || (CONFIG_SMP_NCPUS == 1)
csrw mie, zero
wfi
#endif
/* To get g_cpu_basestack[mhartid], must get g_cpu_basestack first */
la t0, g_cpu_basestack
@ -71,11 +78,6 @@ __start:
li t0, CONFIG_IDLETHREAD_STACKSIZE
add sp, sp, t0
/* In case of single CPU config, stop here */
#if !(defined CONFIG_SMP) || (CONFIG_SMP_NCPUS == 1)
wfi
#endif
2:
/* Disable all interrupts (i.e. timer, external) in mie */