Skip to content

Commit 88fc84d

Browse files
authored
Merge pull request #1839 from ved-rivos/issue_1838
add missing sdt/sie interaction when writing mstatus directly
2 parents fa694e2 + 8566627 commit 88fc84d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

riscv/csrs.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,8 @@ bool mstatus_csr_t::unlogged_write(const reg_t val) noexcept {
556556
const reg_t requested_mpp = proc->legalize_privilege(get_field(val, MSTATUS_MPP));
557557
const reg_t adjusted_val = set_field(val, MSTATUS_MPP, requested_mpp);
558558
reg_t new_mstatus = (read() & ~mask) | (adjusted_val & mask);
559-
if (new_mstatus & MSTATUS_MDT) {
560-
new_mstatus = new_mstatus & ~MSTATUS_MIE;
561-
}
559+
new_mstatus = (new_mstatus & MSTATUS_MDT) ? (new_mstatus & ~MSTATUS_MIE) : new_mstatus;
560+
new_mstatus = (new_mstatus & MSTATUS_SDT) ? (new_mstatus & ~MSTATUS_SIE) : new_mstatus;
562561
maybe_flush_tlb(new_mstatus);
563562
this->val = adjust_sd(new_mstatus);
564563
return true;

0 commit comments

Comments
 (0)