Skip to content

Commit

Permalink
Merge pull request #1839 from ved-rivos/issue_1838
Browse files Browse the repository at this point in the history
add missing sdt/sie interaction when writing mstatus directly
  • Loading branch information
aswaterman authored Oct 19, 2024
2 parents fa694e2 + 8566627 commit 88fc84d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions riscv/csrs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,8 @@ bool mstatus_csr_t::unlogged_write(const reg_t val) noexcept {
const reg_t requested_mpp = proc->legalize_privilege(get_field(val, MSTATUS_MPP));
const reg_t adjusted_val = set_field(val, MSTATUS_MPP, requested_mpp);
reg_t new_mstatus = (read() & ~mask) | (adjusted_val & mask);
if (new_mstatus & MSTATUS_MDT) {
new_mstatus = new_mstatus & ~MSTATUS_MIE;
}
new_mstatus = (new_mstatus & MSTATUS_MDT) ? (new_mstatus & ~MSTATUS_MIE) : new_mstatus;
new_mstatus = (new_mstatus & MSTATUS_SDT) ? (new_mstatus & ~MSTATUS_SIE) : new_mstatus;
maybe_flush_tlb(new_mstatus);
this->val = adjust_sd(new_mstatus);
return true;
Expand Down

0 comments on commit 88fc84d

Please sign in to comment.