diff --git a/riscv/csrs.cc b/riscv/csrs.cc index 647b6827..07be7fbe 100644 --- a/riscv/csrs.cc +++ b/riscv/csrs.cc @@ -412,19 +412,13 @@ bool mstatus_csr_t::unlogged_write(const reg_t val) noexcept { )) proc->get_mmu()->flush_tlb(); - bool has_fs = proc->extension_enabled('S') || proc->extension_enabled('F') - || proc->extension_enabled_const('V'); - bool has_vs = proc->extension_enabled_const('V'); bool has_mpv = proc->extension_enabled('S') && proc->extension_enabled('H'); bool has_gva = has_mpv; - reg_t mask = MSTATUS_MIE | MSTATUS_MPIE | MSTATUS_MPRV | MSTATUS_MPP - | (proc->extension_enabled('S') ? (MSTATUS_SIE | MSTATUS_SPIE | MSTATUS_SPP) : 0) - | MSTATUS_TW | MSTATUS_TSR - | (has_page ? (MSTATUS_MXR | MSTATUS_SUM | MSTATUS_TVM) : 0) - | (has_fs ? MSTATUS_FS : 0) - | (has_vs ? MSTATUS_VS : 0) - | (proc->any_custom_extensions() ? MSTATUS_XS : 0) + reg_t mask = sstatus_write_mask + | MSTATUS_MIE | MSTATUS_MPIE | MSTATUS_MPRV + | MSTATUS_MPP | MSTATUS_TW | MSTATUS_TSR + | (has_page ? MSTATUS_TVM : 0) | (has_gva ? MSTATUS_GVA : 0) | (has_mpv ? MSTATUS_MPV : 0); diff --git a/riscv/csrs.h b/riscv/csrs.h index b591fbd0..6293b8bb 100644 --- a/riscv/csrs.h +++ b/riscv/csrs.h @@ -220,7 +220,7 @@ typedef std::shared_ptr vsstatus_csr_t_p; // state.sstatus. When complete, all references to sstatus that // need to be virtualized will be through this object. // 3. [done] Convert mstatus into a csr_t subclass. -// 4. Refactor common code into base class. +// 4. [done] Refactor common code into base class. // 5. [done] Convert sstatus to a virtualized_csr_t, with a // nonvirtual_sstatus of type sstatus_proxy_csr_t, and // simultaneously remove the swapping of mstatus & vsstatus from