Skip to content

Commit 3e9e06b

Browse files
committed
SPELP field is defined only when S mode is enabled
Signed-off-by: Binno <binno.shen@sifive.com>
1 parent bac3747 commit 3e9e06b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

riscv/csrs.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ reg_t base_status_csr_t::compute_sstatus_write_mask() const noexcept {
449449
| (has_fs ? SSTATUS_FS : 0)
450450
| (proc->any_custom_extensions() ? SSTATUS_XS : 0)
451451
| (has_vs ? SSTATUS_VS : 0)
452-
| (proc->extension_enabled(EXT_ZICFILP) ? SSTATUS_SPELP : 0)
452+
| (proc->extension_enabled('S') && proc->extension_enabled(EXT_ZICFILP) ? SSTATUS_SPELP : 0)
453453
| (proc->extension_enabled(EXT_SSDBLTRP) ? SSTATUS_SDT : 0)
454454
;
455455
}
@@ -562,7 +562,7 @@ bool mstatus_csr_t::unlogged_write(const reg_t val) noexcept {
562562
| (has_gva ? MSTATUS_GVA : 0)
563563
| (has_mpv ? MSTATUS_MPV : 0)
564564
| (proc->extension_enabled(EXT_SMDBLTRP) ? MSTATUS_MDT : 0)
565-
| (proc->extension_enabled(EXT_ZICFILP) ? (MSTATUS_SPELP | MSTATUS_MPELP) : 0)
565+
| (proc->extension_enabled(EXT_ZICFILP) ? (MSTATUS_MPELP | (proc->extension_enabled('S') ? MSTATUS_SPELP : 0)) : 0)
566566
;
567567

568568
const reg_t requested_mpp = proc->legalize_privilege(get_field(val, MSTATUS_MPP));

0 commit comments

Comments
 (0)