Skip to content

Commit

Permalink
firmware: fw_base.S: fix multi-core boot bug.
Browse files Browse the repository at this point in the history
In a multi-core startup scenario, if both _try_lottery and
_wait_for_boot_hart use the data in the _boot_status address, when
a CPU enters OpenSBI later than boot hart set the _boot_status to
BOOT_STATUS_BOOT_HART_DONE, the CPU will modify _boot_status to 1
by amoswap.w and will never be awakened in _wait_for_boot_hart.
So let _try_lottery and _boot_status use data from two addresses.

Signed-off-by: dong.yang <[email protected]>
  • Loading branch information
p7salon authored and xingxg2022 committed Sep 8, 2024
1 parent 537f010 commit fa4ca5a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion firmware/fw_base.S
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ _start:
bne a0, a6, _wait_for_boot_hart
_try_lottery:
/* Jump to relocation wait loop if we don't get relocation lottery */
lla a6, _boot_status
lla a6, _relocate_lottery
li a7, BOOT_STATUS_LOTTERY_DONE
amoswap.w a6, a7, (a6)
bnez a6, _wait_for_boot_hart
Expand Down Expand Up @@ -371,6 +371,8 @@ _skip_trap_handler_hyp:

.data
.align 3
_relocate_lottery:
RISCV_PTR 0
_boot_status:
RISCV_PTR 0

Expand Down

0 comments on commit fa4ca5a

Please sign in to comment.