Skip to contentSkip to conversation

firmware: Do not allow harts with different XLEN to boot

PATCH New Atish Patra 5 participants 6 messages Jun 2, 2021 – Jun 3, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 firmware: Do not allow harts with different XLEN to boot

OpenSBI is built separately for RV32/RV64. Thus, it shouldn't try to boot harts with a different XLEN compared to what it is compiled with.

This patch fixes the issue observed in beagleV which has two U74(RV64) and one E24 (RV32) harts.

---
 firmware/fw_base.S | 10 ++++++++++
 1 file changed, 10 insertions(+)
firmware/fw_base.S +10 -0
index a5ce946aa3fe..ae12a126ca66 100644
@@ -47,6 +47,16 @@
 	.globl _start
 	.globl _start_warm
 _start:
+	csrr   t0, misa
+	slti   t1, t0, 0
+	slli   t1, t1, 1
+	slli   t0, t0, 1
+	slti   t0, t0, 0
+	add    t2, t0, t1
+	li     t3, __riscv_xlen
+	srli   t3, t3, 5
+	bne    t2, t3, _start_hang
+
 	/* Find preferred boot HART id */
 	MOV_3R	s0, a0, s1, a1, s2, a2
 	call	fw_boot_hart
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/1 firmware: Do not allow harts with different XLEN to boot

Quoted 6 lines · Atish Patra

OpenSBI is built separately for RV32/RV64. Thus, it shouldn't try to boot harts with a different XLEN compared to what it is compiled with.

This patch fixes the issue observed in beagleV which has two U74(RV64) and one E24 (RV32) harts.

Is this really necessary? Can the different clusters not boot different OpenSBIs? This is a really gross hack for what seems like a stupid hardware decision if they both blindly load and run from the same place.

Jess

#2 lore raw

PATCH 1/1 firmware: Do not allow harts with different XLEN to boot

Quoted 14 lines

-----Original Message-----
From: Jessica Clarke <[email protected]>
Sent: 02 June 2021 07:25
To: Atish Patra <[email protected]>
Cc: opensbi at lists.infradead.org; Anup Patel <[email protected]>
Subject: Re: [PATCH] firmware: Do not allow harts with different XLEN to boot

Quoted 4 lines · Atish Patra

OpenSBI is built separately for RV32/RV64. Thus, it shouldn't try to boot harts with a different XLEN compared to what it is compiled with.

Quoted 6 lines
Quoted 2 lines

This patch fixes the issue observed in beagleV which has two U74(RV64) and one E24 (RV32) harts.

Is this really necessary? Can the different clusters not boot different OpenSBIs? This is a really gross hack for what seems like a stupid hardware decision if they both blindly load and run from the same place.

Ideally, a platform should boot different OpenSBI firmwares for clusters with differing XLEN.

In any case, if a RV32 HART enters RV64 OpenSBI firmware (or vice-versa) then the HART should enter a WFI hang loop very early.

This patch is more of a precautionary check for platforms like BeagleV where HART with differing XLEN jumps to OpenSBI firmware.

Regards,
Anup

#3 lore raw

PATCH 1/1 firmware: Do not allow harts with different XLEN to boot

? 2021-06-02???? 11:51 +0000?Anup Patel???

Quoted 35 lines
Quoted 21 lines

-----Original Message-----
From: Jessica Clarke <[email protected]>
Sent: 02 June 2021 07:25
To: Atish Patra <[email protected]>
Cc: opensbi at lists.infradead.org; Anup Patel <[email protected]>
Subject: Re: [PATCH] firmware: Do not allow harts with different XLEN to boot

Quoted 9 lines · Atish Patra

OpenSBI is built separately for RV32/RV64. Thus, it shouldn't try to
boot harts with a different XLEN compared to what it is compiled with.

This patch fixes the issue observed in beagleV which has two U74(RV64)
and one E24 (RV32) harts.

Quoted 5 lines

Is this really necessary? Can the different clusters not boot different
OpenSBIs? This is a really gross hack for what seems like a stupid hardware
decision if they both blindly load and run from the same place.

Ideally, a platform should boot different OpenSBI firmwares for clusters
with differing XLEN.

In any case, if a RV32 HART enters RV64 OpenSBI firmware (or vice- versa)
then the HART should enter a WFI hang loop very early.

Quoted 7 lines

This patch is more of a precautionary check for platforms like BeagleV
where HART with differing XLEN jumps to OpenSBI firmware.

Regards,
Anup

MXL can be modified, if it does not match, whether to try to modify MXL, and then continue to run

Regards,
Xiang W

#4 lore raw

PATCH 1/1 firmware: Do not allow harts with different XLEN to boot

In reply to Atish Patra
Quoted 28 lines

-----Original Message-----
From: Atish Patra <[email protected]>
Sent: 02 June 2021 07:12
To: opensbi at lists.infradead.org
Cc: Anup Patel <[email protected]>; Atish Patra <[email protected]>
Subject: [PATCH] firmware: Do not allow harts with different XLEN to boot

OpenSBI is built separately for RV32/RV64. Thus, it shouldn't try to boot harts with a different XLEN compared to what it is compiled with.

This patch fixes the issue observed in beagleV which has two U74(RV64) and one E24 (RV32) harts.

---
 firmware/fw_base.S | 10 ++++++++++
 1 file changed, 10 insertions(+)
firmware/fw_base.S index renamed from firmware/fw_base.S +0 -0

a5ce946aa3fe..ae12a126ca66 100644

firmware/fw_base.S +0 -0
@@ -47,6 +47,16 @@
 	.globl _start
 	.globl _start_warm
 _start:

firmware/fw_base.S line 59

Quoted 10 lines
firmware/fw_base.S +10 -0
+	csrr   t0, misa
+	slti   t1, t0, 0
+	slli   t1, t1, 1
+	slli   t0, t0, 1
+	slti   t0, t0, 0
+	add    t2, t0, t1
+	li     t3, __riscv_xlen
+	srli   t3, t3, 5
+	bne    t2, t3, _start_hang
+

Unfortunately, MISA can be wired to zero in which case platform will provide non-standard hooks to check extensions.

How about this ?

	li    t0, 1
	slli t0, t0, 32

#if __riscv_xlen == 32
bne t0, zero, _start_hang
#else
beq t0, zero, _start_hang
#endif

Probably above can be ASM macro so that we can call this macro at start of both _start() and _start_warm()

Quoted 5 lines
firmware/fw_base.S +0 -1
 	/* Find preferred boot HART id */
 	MOV_3R	s0, a0, s1, a1, s2, a2
 	call	fw_boot_hart
--

2.31.1

Regards,
Anup

#5 lore raw

PATCH 1/1 firmware: Do not allow harts with different XLEN to boot

Quoted 48 lines · Anup Patel
Quoted 29 lines

-----Original Message-----
From: Atish Patra <[email protected]>
Sent: 02 June 2021 07:12
To: opensbi at lists.infradead.org
Cc: Anup Patel <[email protected]>; Atish Patra <[email protected]>
Subject: [PATCH] firmware: Do not allow harts with different XLEN to boot

OpenSBI is built separately for RV32/RV64. Thus, it shouldn't try to boot harts with a different XLEN compared to what it is compiled with.

This patch fixes the issue observed in beagleV which has two U74(RV64) and one E24 (RV32) harts.

---
 firmware/fw_base.S | 10 ++++++++++
 1 file changed, 10 insertions(+)
firmware/fw_base.S index renamed from firmware/fw_base.S +0 -0

a5ce946aa3fe..ae12a126ca66 100644

firmware/fw_base.S +0 -0
@@ -47,6 +47,16 @@
      .globl _start
      .globl _start_warm
 _start:

firmware/fw_base.S line 59

Quoted 10 lines
firmware/fw_base.S +10 -0
+     csrr   t0, misa
+     slti   t1, t0, 0
+     slli   t1, t1, 1
+     slli   t0, t0, 1
+     slti   t0, t0, 0
+     add    t2, t0, t1
+     li     t3, __riscv_xlen
+     srli   t3, t3, 5
+     bne    t2, t3, _start_hang
+

Unfortunately, MISA can be wired to zero in which case platform will provide non-standard hooks to check extensions.

How about this ?

        li    t0, 1
        slli t0, t0, 32
Quoted 9 lines

#if __riscv_xlen == 32
bne t0, zero, _start_hang
#else
beq t0, zero, _start_hang
#endif

Probably above can be ASM macro so that we can call this macro at start of both _start() and _start_warm()

Sure. I will do that.

Just to clarify, we don't need this for Beagleboard.
After talking to StarFive engineers, it was confirmed that the U74 and E24 are in different clusters and both contain hart0.
However, E24 never enters OpenSBI as it executes code compiled for RV32 only.

This patch will just serve as an improved sanity check.

Quoted 14 lines
Quoted 5 lines
firmware/fw_base.S +0 -1
      /* Find preferred boot HART id */
      MOV_3R  s0, a0, s1, a1, s2, a2
      call    fw_boot_hart
--

2.31.1

Regards,
Anup

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

Signature · 2 lines
Regards,
Atish