[PATCH] firmware: fw_base: make stack guard setup conditional on Zkr
buenocalvachejoel at gmail.com
buenocalvachejoel at gmail.com
Tue Mar 31 02:59:43 PDT 2026
From: Joel Bueno <buenocalvachejoel at gmail.com>
Zkr isn't explicitly selected as a mandatory extension to run OpenSBI
as per: docs/platform_requirements.md
Since this happens very early on the boot flow of OpenSBI where the
dynamic extension checks haven't yet happened, we must guard the Zkr
stack setup behind an ifdef block so that it only gets compiled for
targets that do actually have the extension.
Signed-off-by: Joel Bueno <buenocalvachejoel at gmail.com>
---
firmware/fw_base.S | 2 ++
1 file changed, 2 insertions(+)
diff --git a/firmware/fw_base.S b/firmware/fw_base.S
index 63bb4473..9ea93907 100644
--- a/firmware/fw_base.S
+++ b/firmware/fw_base.S
@@ -107,6 +107,7 @@ _bss_zero:
add s4, s4, __SIZEOF_POINTER__
blt s4, s5, _bss_zero
+#if defined(__riscv_zkr)
/* Trying to initialize the stack guard via the Zkr extension */
lla t0, __stack_chk_guard_done
csrw CSR_MTVEC, t0
@@ -130,6 +131,7 @@ __stack_chk_guard_loop:
j __stack_chk_guard_done
.align 3
__stack_chk_guard_done:
+#endif
/* Setup temporary trap handler */
lla s4, _start_hang
--
2.43.0
More information about the opensbi
mailing list