This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new b7d2b38700 risc-v/mpfs: opensbi: fix random boot failures
b7d2b38700 is described below
commit b7d2b387009ae11a37c13ed75ea7ba764cb46288
Author: Eero Nurkkala <[email protected]>
AuthorDate: Fri Nov 4 15:56:45 2022 +0200
risc-v/mpfs: opensbi: fix random boot failures
After the commit b8b541f, the system would not start up properly
with certain coldboot conditions. For example, if the OpenSBI picked
hart4 as the coldboot hart in preference to hart3, the system would
get stuck due to stack corruption. OpenSBI uses a lottery mechanism
to pick the coldboot hart.
Also fix g_scratches area in such a manner than it will not get
initialized to zero. If several harts initialize the area to zero, there's
danger the stack pointer gets wiped out.
Now any coldboot hart works.
Signed-off-by: Eero Nurkkala <[email protected]>
---
arch/risc-v/src/mpfs/mpfs_opensbi.c | 2 +-
arch/risc-v/src/mpfs/mpfs_opensbi_utils.S | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/risc-v/src/mpfs/mpfs_opensbi.c
b/arch/risc-v/src/mpfs/mpfs_opensbi.c
index 769e9075a0..866c29fa20 100644
--- a/arch/risc-v/src/mpfs/mpfs_opensbi.c
+++ b/arch/risc-v/src/mpfs/mpfs_opensbi.c
@@ -225,7 +225,7 @@ static const struct sbi_platform platform =
/* This must go into l2_scratchpad region, starting at 0x0a000000. */
-sbi_scratch_holder_t g_scratches[MPFS_MAX_NUM_HARTS] \
+sbi_scratch_holder_t g_scratches[0] \
__attribute__((section(".l2_scratchpad")));
/****************************************************************************
diff --git a/arch/risc-v/src/mpfs/mpfs_opensbi_utils.S
b/arch/risc-v/src/mpfs/mpfs_opensbi_utils.S
index 92627feb25..b933bdb5d4 100644
--- a/arch/risc-v/src/mpfs/mpfs_opensbi_utils.S
+++ b/arch/risc-v/src/mpfs/mpfs_opensbi_utils.S
@@ -103,7 +103,6 @@ mpfs_opensbi_prepare_hart:
mul t0, a0, t1
la sp, g_scratches
add sp, sp, t0
- add sp, sp, t1
jal mpfs_opensbi_setup
/****************************************************************************