summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadim Krčmář <[email protected]>2025-04-29 16:25:47 +0200
committerAnup Patel <[email protected]>2025-04-30 10:14:26 +0530
commit8c814b5c9b03aac0d6bb2366e3c8fbce132ca4d9 (patch)
treea29074c3a5768f32f7368f34c5945905458c9e92
parent6b877fb53b8da84c69f0832c7f2a343239ba609e (diff)
lib: sbi_hart: fix sstateen emulation
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. Reviewed-by: Anup Patel <[email protected]> Signed-off-by: Radim Krčmář <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
-rw-r--r--lib/sbi/sbi_hart.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index bdf66ef7..fc37b249 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);