-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SailBugfix: Modifies only mie in write Sie when the interrupt is dele… #383
Conversation
3ac2a9a
to
5dd6663
Compare
I see what you want to do here, shouldn't it simply be: // Only delegated interrupts can be enabled through `sie`
let mideleg = self.get(Csr::Mideleg);
self.csr.mie = (self.csr.mie & !mideleg) | (mideleg & value); where all delegated interrupts can be modified? |
The two formulations are not equivalent. In the case mideleg is set to 0 you don't want to change the value of the bit. Therefore we need three if statements ^^ You can't beat kani ^^ |
Well yes indeed, and the proposed code snipped does not change any value when The reason I am asking is because the version in the PR is missing the LCOFIE bit, which is not it the Sail model but is present on the hardware, so we would need at least a 4th |
The problem is that if only one of the interrupt is delegated, with the previous implementation we can clear the entire mask which is wrong. Regarding lcofie, let me fix that |
5dd6663
to
62d478c
Compare
@CharlyCst Ready for review! I did the change |
Yes, I agree the previous implementation was wrong, but is: // Only delegated interrupts can be enabled through `sie`
let mideleg = self.get(Csr::Mideleg);
self.csr.mie = (self.csr.mie & !mideleg) | (mideleg & value); Correct? That was my question ^^ |
This also looks correct, let me test with kani |
62d478c
to
46440cb
Compare
Works, pushed |
…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.
46440cb
to
ea2d4a2
Compare
…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.