diff options
author | sven <zhongcy93@gmail.com> | 2021-12-16 18:27:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-16 02:27:26 -0800 |
commit | d1f2019ec1b412503a23a77bc1939693260e1966 (patch) | |
tree | a6663276ef089d85afeaf652501fd352affd8b8f | |
parent | 0f30988e4d0e8daac893834b91979f7700bab481 (diff) | |
download | spike-d1f2019ec1b412503a23a77bc1939693260e1966.zip spike-d1f2019ec1b412503a23a77bc1939693260e1966.tar.gz spike-d1f2019ec1b412503a23a77bc1939693260e1966.tar.bz2 |
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)
-rw-r--r-- | riscv/csrs.cc | 3 |
1 files changed, 2 insertions, 1 deletions
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); |