From 4c10fbe07b3f8f5f73871cec21f5ac3758c94c41 Mon Sep 17 00:00:00 2001 From: pointerliu Date: Wed, 21 Jan 2026 11:13:37 +0800 Subject: [PATCH] csrs.cc: if no U-mode, mstatus.tw is read-only 0 --- riscv/csrs.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/riscv/csrs.cc b/riscv/csrs.cc index 1e751c99..249c76d5 100644 --- a/riscv/csrs.cc +++ b/riscv/csrs.cc @@ -556,7 +556,8 @@ bool mstatus_csr_t::unlogged_write(const reg_t val) noexcept { const reg_t mask = adj_write_mask | MSTATUS_MIE | MSTATUS_MPIE | (proc->extension_enabled('U') ? MSTATUS_MPRV : 0) - | MSTATUS_MPP | MSTATUS_TW + | MSTATUS_MPP + | (proc->extension_enabled('U') ? MSTATUS_TW : 0) | (proc->extension_enabled('S') ? MSTATUS_TSR : 0) | (has_page ? MSTATUS_TVM : 0) | (has_gva ? MSTATUS_GVA : 0)