-
Couldn't load subscription status.
- Fork 160
fix(riscv/irqc): align IMSIC handler to AIA specifications #209
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
base: main
Are you sure you want to change the base?
Conversation
9dc1917 to
cc18264
Compare
|
Had to force push because of the failing format check, I wanted to keep the change small but clang-format doesn't like it 🥲. |
cc18264 to
bb4277d
Compare
|
Thanks again for fixing this @filippofontana! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just maybe ask you to split the PR in two commits. One for the new csrs accessors the other for the interrupt handle fix.
|
Ok, sure! |
This commit adds a "logical" swap operation to the CSR registers accessors. It is implemented with the `csrrw` instruction under the hood. Signed-off-by: Filippo Fontana <[email protected]>
"The RISC-V Advanced Interrupt Architecture" specifications explain in Chapter 3 (pages 26-27) how interrupts should be handled with IMSIC, in particular, interrupt claiming has to be done right after reading the STOPEI register or in the same read instruction with the csrrw instruction. This commit aligns the IMSIC interrupt handler to that specs. Without this change, if an interrupt with higher priority becomes pending while handling a lower one, writing to STOPEI after `interrupts_handle()` executes will claim the higher IRQ, freezing the execution. Signed-off-by: Filippo Fontana <[email protected]>
3cf36d6 to
a6c0c1b
Compare
"The RISC-V Advanced Interrupt Architecture" specifications explain in Chapter 3 (pages 26-27) how interrupts should be handled with IMSIC, in particular, interrupt claiming has to be done right after reading the STOPEI register or in the same read instruction with the csrrw instruction.
This commit aligns the IMSIC interrupt handler to that specs. Without this change, if an interrupt with higher priority becomes pending while handling a lower one, writing to STOPEI after
interrupts_handle()executes will claim the higher IRQ, freezing the execution.