diff options
author | Bo Gan <ganboing@gmail.com> | 2023-06-11 16:54:17 -0700 |
---|---|---|
committer | Leo Yu-Chi Liang <ycliang@andestech.com> | 2023-07-24 13:17:26 +0800 |
commit | 28ff3f16c432f53670d4f3867f003e0a86a5e1e6 (patch) | |
tree | d5b8649cab72a057c2b44e223bbbcd12107ff3e4 /lib/efi_loader/efi_variable_tee.c | |
parent | 247aa5a191159ea7e03bf1918e22fbbb784cd410 (diff) |
riscv: setup per-hart stack earlier
Harts need to use per-hart stack before any function call, even if that
function is a simple one. When the callee uses stack for register save/
restore, especially RA, if nested call, concurrent access by multiple
harts on the same stack will cause data-race.
This patch sets up SP before `board_init_f_alloc_reserve`. A side effect
of this is that the memory layout has changed as the following:
+----------------+ +----------------+ <----- SPL_STACK/
| ...... | | hart 0 stack | SYS_INIT_SP_ADDR
| malloc_base | +----------------+
+----------------+ | hart 1 stack |
| GD | +----------------+ If not SMP, N=1
+----------------+ | ...... |
| hart 0 stack | +----------------+
+----------------+ ==> | hart N-1 stack|
| hart 1 stack | +----------------+
+----------------+ | ...... |
| ...... | | malloc_base |
+----------------+ +----------------+
| hart N-1 stack| | GD |
+----------------+ +----------------+
| | | |
Signed-off-by: Bo Gan <ganboing@gmail.com>
Cc: Rick Chen <rick@andestech.com>
Cc: Leo <ycliang@andestech.com>
Cc: Sean Anderson <seanga2@gmail.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Reviewed-by: Rick Chen <rick@andestech.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
Diffstat (limited to 'lib/efi_loader/efi_variable_tee.c')
0 files changed, 0 insertions, 0 deletions