[RFC PATCH 03/12] lib: sbi_hart: enforce riscv,pmwid for Worlds ISA
Yu-Chien Peter Lin
peter.lin at sifive.com
Fri Jun 26 03:14:24 PDT 2026
When Smwid/Smlwid extensions are detected during hart ISA detection,
the riscv,pmwid device tree property is required to specify the M-mode
WID default value.
Signed-off-by: Yu-Chien Peter Lin <peter.lin at sifive.com>
---
lib/sbi/sbi_hart.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index 0c584bfc..cb0c66ea 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -768,6 +768,19 @@ skip_smwiddeleg:
/* Mark hart feature detection done */
hfeatures->detected = true;
+ /*
+ * Validate M-mode WID default value: if Worlds ISA extensions
+ * are present, riscv,pmwid must exist in DT.
+ */
+ if ((sbi_hart_has_extension(scratch, SBI_HART_EXT_SMWID) ||
+ sbi_hart_has_extension(scratch, SBI_HART_EXT_SMLWID)) &&
+ !hfeatures->has_pmwid) {
+ sbi_printf("WARNING: hart%u has Worlds ISA extension but DT "
+ "lacks riscv,pmwid.\n",
+ current_hartid());
+ return SBI_EINVAL;
+ }
+
/*
* On platforms with Smepmp, the previous booting stage must
* enter OpenSBI with mseccfg.MML == 0. This allows OpenSBI
--
2.43.7
More information about the opensbi
mailing list