Failure with 4 nested interrupts
I'm trying to play with nested interrupts. So I made a basic simulation where 4 fast interrupts irq_fast_i[3:0] are generated in a row. Upon exit from the 4th (last) interrupt routine, the simulation crashes since PC gets mtvec value. Besides I noticed that MPP unexpectedly (in my opinion) gets PRIV_LVL_U value taken from mstack_q.mpp upon exit from 2nd interrupt.

Here's link to VCD of the whole simulation: https://drive.google.com/file/d/1_tCNmXmqjzP6HRwKA9owZvmAPoSzf3ov/view?usp=sharing
Program code listing file: https://drive.google.com/file/d/1C4Vwz_DSkY86ZZbylEyhloTzgiSTvSJ6/view?usp=sharing
Thanks for the detailed report @vit82 - You're right it's incorrect for the core to jump to U-mode. Looking at it, I'm not sure how nested interrupts are possible with these non-standard mstack registers since they can't be written to. I'll look into it.
@udinator can you comment on the testing to date of nested interrupts?
On Wed, Nov 13, 2019 at 7:50 AM Tom Roberts [email protected] wrote:
Thanks for the detailed report @vit82 https://github.com/vit82 - You're right it's incorrect for the core to jump to U-mode. Looking at it, I'm not sure how nested interrupts are possible with these non-standard mstack registers since they can't be written to. I'll look into it.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lowRISC/ibex/issues/469?email_source=notifications&email_token=AJZQKVNJOWAWMWD72ZLSBMLQTQO2VA5CNFSM4JM4DZHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOED6S2QI#issuecomment-553463105, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJZQKVJAKKA2GKA5YFIIF3TQTQO2VANCNFSM4JM4DZHA .
@sjgitty - I haven't tested nested traps at all as of right now, that is something that I had planned to work on after U-mode verification is done.
Hi @vit82 I looked into the waves and your sample code.
I believe the problem will be fixed by also saving the mstatus register to the stack (along with mepc) before re-enabling interrupts. The mstatus register should then be restored before executing mret.
Ignoring the non-standard mstack registers for a moment, the RISCV priv spec states that on executing an mret instruction, mstatus.MPP should be set to U-mode. So in nested interrupts, executing multiple mret instructions without restoring the previous interrupt context will drop you down into U-mode.
The mstack registers effectively do this for you for one level of nesting, but for further levels the software must handle it by stacking the interrupt context.
Apologies for the delay in getting back to you, there doesn't seem to be any decent example available for how to handle nested interrupts!
Thanks! Putting the register mstatus on stack solved the issue!
@vit82 great that it works! Would you mind sharing a bit of example code that shows the entry/exit from a interrupt when using nested interrupts? That's something we really should put into our user guide. Or even better, would you mind doing a pull request with some documentation, e.g. added to https://github.com/lowRISC/ibex/blob/master/doc/exception_interrupts.rst?
@sjgitty - I haven't tested nested traps at all as of right now, that is something that I had planned to work on after U-mode verification is done.
May you, please, share the status of IBEX verification activities? Is there an access to verification plan?
Hi @vit82 - As our verification of Ibex core is part of the larger OpenTitan verification effort, a DV status for the core can be found here, and complies with the OpenTitan Verification milestone checklist, found here. Regarding the verification plan, as we are verifying the core by using the Google developed RISC-V Instruction Generator as explained in the verification documentation, the existing regression list is found here. Feel free to let me know if you have any question/concerns!
Thanks, @udinator , is there a possibility to track progress of verification? In the regression list you pointed I couldn't find status of the test cases (pass/fail) or other metrics (e.g. functional coverage).
By the way, is there a viewer to display conveniently yaml files?
Hi @vit82 , apologies for late response. As of right now, there is no progress/coverage tracker for Ibex verification, the regression list just displays the test case configuration to pass into the simulation flow. As far as yaml files, I just open them in a text editor to display them, as it is just another formatting language similar to hjson format.