fw_base.S: Fix boot hart status synchronization
PATCH 1/1 fw_base.S: Fix boot hart status synchronization
From: Guo Ren <[email protected]>
It's wrong to put the fence after setting the boot status flag because all relocation operations must be finished before setting the status flag. So, this fence must be put before the setting status flag, and there is no use in putting a fence between _start_warm and setting status flag.
Also, nop can't delay other harts too much, so use div instead, just like Linux cpu_relax. Current opensbi force enables ?M? Standard Extension, and mul instructions have been used in the fw_base.S.
After the above two fixes, the boot hart index param of the fw_dynamic_info could be guaranteed properly for all platforms.
--- firmware/fw_base.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
firmware/fw_base.S +4 -4
@@ -399,8 +399,8 @@ _fdt_reloc_done: /* mark boot hart done */ li t0, BOOT_STATUS_BOOT_HART_DONE lla t1, _boot_status - REG_S t0, 0(t1) fence rw, rw + REG_S t0, 0(t1) j _start_warm /* waiting for boot hart to be done (_boot_status == 2) */
@@ -409,9 +409,9 @@ _wait_for_boot_hart: lla t1, _boot_status REG_L t1, 0(t1) /* Reduce the bus traffic so that boot hart may proceed faster */ - nop - nop - nop + div t2, t2, zero + div t2, t2, zero + div t2, t2, zero bne t0, t1, _wait_for_boot_hart _start_warm:
Signature · 1 line
2.36.1
PATCH 1/1 fw_base.S: Fix boot hart status synchronization
F.Y.I Drew
This patch is also needed for "zsb -> opensbi -> linux"
Quoted 50 lines · On Thu, Oct 19, 2023 at 5:27?PM <[email protected]> wrote:
From: Guo Ren <[email protected]>
It's wrong to put the fence after setting the boot status flag because all relocation operations must be finished before setting the status flag. So, this fence must be put before the setting status flag, and there is no use in putting a fence between
_start_warmand setting status flag.Also, nop can't delay other harts too much, so use div instead, just like Linux
cpu_relax. Current opensbi force enables ?M? Standard Extension, and mul instructions have been used in thefw_base.S.After the above two fixes, the boot hart index param of the
fw_dynamic_infocould be guaranteed properly for all platforms.Signed-off-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>--- firmware/fw_base.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)firmware/fw_base.S +4
-5@@ -399,8 +399,8 @@ _fdt_reloc_done: /* mark boot hart done */ li t0, BOOT_STATUS_BOOT_HART_DONE lla t1, _boot_status - REG_S t0, 0(t1) fence rw, rw + REG_S t0, 0(t1) j _start_warm /* waiting for boot hart to be done (_boot_status == 2) */@@ -409,9 +409,9 @@ _wait_for_boot_hart: lla t1, _boot_status REG_L t1, 0(t1) /* Reduce the bus traffic so that boot hart may proceed faster */ - nop - nop - nop + div t2, t2, zero + div t2, t2, zero + div t2, t2, zero bne t0, t1, _wait_for_boot_hart _start_warm: --
Quoted 2 lines
2.36.1
--
Best Regards
Guo Ren
Anup Patel
AppliedPATCH 1/1 fw_base.S: Fix boot hart status synchronization
In reply to [email protected]Quoted 13 lines · On Thu, Oct 19, 2023 at 2:57?PM <[email protected]> wrote:
From: Guo Ren <[email protected]>
It's wrong to put the fence after setting the boot status flag because all relocation operations must be finished before setting the status flag. So, this fence must be put before the setting status flag, and there is no use in putting a fence between
_start_warmand setting status flag.Also, nop can't delay other harts too much, so use div instead, just like Linux
cpu_relax. Current opensbi force enables ?M? Standard Extension, and mul instructions have been used in thefw_base.S.
Quoted 5 lines
After the above two fixes, the boot hart index param of the
fw_dynamic_infocould be guaranteed properly for all platforms.Signed-off-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>
Looks good to me.
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
Quoted 34 lines
--- firmware/fw_base.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)firmware/fw_base.S +4
-5@@ -399,8 +399,8 @@ _fdt_reloc_done: /* mark boot hart done */ li t0, BOOT_STATUS_BOOT_HART_DONE lla t1, _boot_status - REG_S t0, 0(t1) fence rw, rw + REG_S t0, 0(t1) j _start_warm /* waiting for boot hart to be done (_boot_status == 2) */@@ -409,9 +409,9 @@ _wait_for_boot_hart: lla t1, _boot_status REG_L t1, 0(t1) /* Reduce the bus traffic so that boot hart may proceed faster */ - nop - nop - nop + div t2, t2, zero + div t2, t2, zero + div t2, t2, zero bne t0, t1, _wait_for_boot_hart _start_warm: --2.36.1