Skip to content

Commit

Permalink
SailBugfix: scounteren is read-only except for IR, TMP, and CY fields
Browse files Browse the repository at this point in the history
This commit makes all bits in the mcounteren register read-only, except for the aforementioned IR, TMP, and CY fields, which remain writable.
  • Loading branch information
francois141 authored and CharlyCst committed Dec 2, 2024
1 parent b8578cb commit dbd8d9d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/virt/csr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,10 @@ impl HwRegisterContextSetter<Csr> for VirtContext {
}
}
}
Csr::Scounteren => (), // Read-only 0
Csr::Scounteren => {
// Only show IR, TM and CY (for cycle, time and instret counters)
self.csr.scounteren = (self.csr.scounteren & !0b111) | (value & 0b111) as u32
}
Csr::Senvcfg => self.csr.senvcfg = value,
Csr::Sscratch => self.csr.sscratch = value,
Csr::Sepc => {
Expand Down

0 comments on commit dbd8d9d

Please sign in to comment.