From d1f2019ec1b412503a23a77bc1939693260e1966 Mon Sep 17 00:00:00 2001 From: sven Date: Thu, 16 Dec 2021 18:27:26 +0800 Subject: TSR is read-only 0 when S-mode is not supported. (#890) According the privileged spec, TSR is read-only 0 when S-mode is not supported. (https://github.com/riscv/riscv-isa-manual/blob/56515289e5999512fe578cdddf861b730d790018/src/machine.tex#L860-L861) --- riscv/csrs.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/riscv/csrs.cc b/riscv/csrs.cc index fdcfc94..49b505b 100644 --- a/riscv/csrs.cc +++ b/riscv/csrs.cc @@ -439,7 +439,8 @@ bool mstatus_csr_t::unlogged_write(const reg_t val) noexcept { const reg_t mask = sstatus_write_mask | MSTATUS_MIE | MSTATUS_MPIE | MSTATUS_MPRV - | MSTATUS_MPP | MSTATUS_TW | MSTATUS_TSR + | MSTATUS_MPP | MSTATUS_TW + | (proc->extension_enabled('S') ? MSTATUS_TSR : 0) | (has_page ? MSTATUS_TVM : 0) | (has_gva ? MSTATUS_GVA : 0) | (has_mpv ? MSTATUS_MPV : 0); -- cgit v1.1