[PATCH 5/8] lib: sbi_hart: fix sstateen emulation
Radim Krčmář
rkrcmar at ventanamicro.com
Tue Apr 15 06:19:06 PDT 2025
The Sstateen extension defines 4 sstateen registers, but SBI currently
configures the execution environment to throw illegal instruction
exception when accessing sstateen1-3.
SBI should implement all sstateen registers, so delegate the
implementation to hardware by setting the SE bit.
Signed-off-by: Radim Krčmář <rkrcmar at ventanamicro.com>
---
lib/sbi/sbi_hart.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index c280c0b3e85e..b209f1cab27d 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -111,6 +111,9 @@ static void mstatus_init(struct sbi_scratch *scratch)
mstateen_val &= ~SMSTATEEN0_CTR;
csr_write64(CSR_MSTATEEN0, mstateen_val);
+ csr_write64(CSR_MSTATEEN1, SMSTATEEN_STATEN);
+ csr_write64(CSR_MSTATEEN2, SMSTATEEN_STATEN);
+ csr_write64(CSR_MSTATEEN3, SMSTATEEN_STATEN);
if (misa_extension('S'))
csr_write(CSR_SSTATEEN0, 0);
--
2.48.1
More information about the opensbi
mailing list