diff options
author | Udit Khanna <40774742+khannaudit@users.noreply.github.com> | 2020-02-27 15:23:33 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-27 15:23:33 -0800 |
commit | f6290f604c3369d23637de07a2c1be9773c2d4d9 (patch) | |
tree | 7af58fc97efd704c80573a8f57cc8f484ed3b463 | |
parent | 7d9a624bbe4ca5a51bb6b4a8c3653c668b2a9200 (diff) | |
parent | e470c1bcc26b8b2148608007f4592d86f491de3c (diff) | |
download | riscv-isa-sim-f6290f604c3369d23637de07a2c1be9773c2d4d9.zip riscv-isa-sim-f6290f604c3369d23637de07a2c1be9773c2d4d9.tar.gz riscv-isa-sim-f6290f604c3369d23637de07a2c1be9773c2d4d9.tar.bz2 |
Merge pull request #405 from riscv/mstatus-sxl-uxl
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 e4a5f6c..d458e39 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -610,11 +610,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); @@ -631,8 +630,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; |