diff options
author | Udit Khanna <udit.khanna@sifive.com> | 2020-02-27 04:30:04 -0800 |
---|---|---|
committer | Udit Khanna <udit.khanna@sifive.com> | 2020-02-27 15:15:46 -0800 |
commit | e470c1bcc26b8b2148608007f4592d86f491de3c (patch) | |
tree | 6feb26a53a390767b0a9de3c6ee2d2275c7a8fd0 | |
parent | 76e211d53e8e5ce7a6f2b44703c7fb31db8d5d0e (diff) | |
download | riscv-isa-sim-e470c1bcc26b8b2148608007f4592d86f491de3c.zip riscv-isa-sim-e470c1bcc26b8b2148608007f4592d86f491de3c.tar.gz riscv-isa-sim-e470c1bcc26b8b2148608007f4592d86f491de3c.tar.bz2 |
Check presence of [S|U] extension for mstatus.[sxl|uxl] read/write
-rw-r--r-- | riscv/processor.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/riscv/processor.cc b/riscv/processor.cc index 383fd3f..9f8ca06 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -608,11 +608,10 @@ void processor_t::set_csr(int which, reg_t val) reg_t mask = MSTATUS_SIE | MSTATUS_SPIE | MSTATUS_MIE | MSTATUS_MPIE | MSTATUS_MPRV | (supports_extension('S') ? MSTATUS_SUM : 0) - | MSTATUS_MXR | MSTATUS_TW | MSTATUS_TVM - | MSTATUS_TSR | MSTATUS_UXL | MSTATUS_SXL | - (has_fs ? MSTATUS_FS : 0) | - (has_vs ? MSTATUS_VS : 0) | - (ext ? MSTATUS_XS : 0); + | MSTATUS_MXR | MSTATUS_TW | MSTATUS_TVM | MSTATUS_TSR + | (has_fs ? MSTATUS_FS : 0) + | (has_vs ? MSTATUS_VS : 0) + | (ext ? MSTATUS_XS : 0); reg_t requested_mpp = legalize_privilege(get_field(val, MSTATUS_MPP)); state.mstatus = set_field(state.mstatus, MSTATUS_MPP, requested_mpp); @@ -629,8 +628,10 @@ void processor_t::set_csr(int which, reg_t val) else state.mstatus = set_field(state.mstatus, MSTATUS64_SD, dirty); - state.mstatus = set_field(state.mstatus, MSTATUS_UXL, xlen_to_uxl(max_xlen)); - state.mstatus = set_field(state.mstatus, MSTATUS_SXL, xlen_to_uxl(max_xlen)); + if (supports_extension('U')) + state.mstatus = set_field(state.mstatus, MSTATUS_UXL, xlen_to_uxl(max_xlen)); + if (supports_extension('S')) + state.mstatus = set_field(state.mstatus, MSTATUS_SXL, xlen_to_uxl(max_xlen)); // U-XLEN == S-XLEN == M-XLEN xlen = max_xlen; break; |