aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadim Krčmář <rkrcmar@ventanamicro.com>2025-04-29 16:25:47 +0200
committerAnup Patel <anup@brainfault.org>2025-04-30 10:14:26 +0530
commit8c814b5c9b03aac0d6bb2366e3c8fbce132ca4d9 (patch)
treea29074c3a5768f32f7368f34c5945905458c9e92
parent6b877fb53b8da84c69f0832c7f2a343239ba609e (diff)
downloadopensbi-8c814b5c9b03aac0d6bb2366e3c8fbce132ca4d9.zip
opensbi-8c814b5c9b03aac0d6bb2366e3c8fbce132ca4d9.tar.gz
opensbi-8c814b5c9b03aac0d6bb2366e3c8fbce132ca4d9.tar.bz2
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 <anup@brainfault.org> Signed-off-by: Radim Krčmář <rkrcmar@ventanamicro.com> Link: https://lore.kernel.org/r/20250429142549.3673976-7-rkrcmar@ventanamicro.com Signed-off-by: Anup Patel <anup@brainfault.org>
-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 bdf66ef..fc37b24 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);