Skip to content

Commit

Permalink
SailBugfix: Modifies only mie in write Sie when the interrupt is dele…
Browse files Browse the repository at this point in the history
…gated

Before modifying each specific interrupt enable bit (e.g., SEIE, STIE, or SSIE), the code checks whether the corresponding bit in Mideleg is set. Mideleg determines whether a specific interrupt is delegated to the supervisor level, so this ensures that only interrupts managed by the supervisor are updated.
  • Loading branch information
francois141 authored and CharlyCst committed Jan 28, 2025
1 parent ebd7896 commit ea2d4a2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/virt/csr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,9 @@ impl HwRegisterContextSetter<Csr> for VirtContext {
);
}
Csr::Sie => {
// Clear S bits
let mie = self.get(Csr::Mie) & !mie::SIE_FILTER;
// Set S bits to new value
self.set_csr(Csr::Mie, mie | (value & mie::SIE_FILTER), mctx);
// Only delegated interrupts can be enabled through `sie`
let mideleg = self.get(Csr::Mideleg);
self.csr.mie = (self.csr.mie & !mideleg) | (mideleg & value);
}
Csr::Stvec => {
match value & 0b11 {
Expand Down

0 comments on commit ea2d4a2

Please sign in to comment.