Skip to content

Commit b92958a

Browse files
authored
Merge pull request #2216 from pointerliu/fix-tw-read
csrs.cc: if no U-mode, mstatus.tw is read-only 0
2 parents efdaa08 + 4c10fbe commit b92958a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

riscv/csrs.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,8 @@ bool mstatus_csr_t::unlogged_write(const reg_t val) noexcept {
556556
const reg_t mask = adj_write_mask
557557
| MSTATUS_MIE | MSTATUS_MPIE
558558
| (proc->extension_enabled('U') ? MSTATUS_MPRV : 0)
559-
| MSTATUS_MPP | MSTATUS_TW
559+
| MSTATUS_MPP
560+
| (proc->extension_enabled('U') ? MSTATUS_TW : 0)
560561
| (proc->extension_enabled('S') ? MSTATUS_TSR : 0)
561562
| (has_page ? MSTATUS_TVM : 0)
562563
| (has_gva ? MSTATUS_GVA : 0)

0 commit comments

Comments
 (0)