Catching an interrupt that broke debug single stepping
A closed bug report on a RISC-V core: an interrupt during a debug single step let a handler instruction run. We reproduced it and proved the maintainers' fix holds.
1The issue
In debug single step mode, the core runs one instruction and then stops for the debugger. The report said that an interrupt during a step could make the core run the wrong number of instructions. The RISC-V debug spec says that once an interrupt is taken during a step, the core must stop for debug before any instruction of the interrupt handler finishes. The core let one handler instruction finish first.
The points on the issue
2What we did
- 1Wrote a rule from the debug spec: once an interrupt is taken during a step, no handler instruction may finish until the core enters debug mode.
- 2Ran it with formal verification, which checks every reachable state, on the design from before the fix. The tool found a case where a handler instruction finished one step before the core entered debug.
- 3Ran the same rule on the current design. It holds for every reachable state, and a bounded check 30 steps deep also passes.
- 4Read the fix by the core's maintainers only after the proof. It makes the core stop for debug on the interrupt itself, the same event our rule watches.
3Result
The bug is reproduced on the design before the fix, and the rule holds on the current design. With the fix, debug is entered in the cycle after the interrupt, at the handler address.
The core's maintainers wrote the fix, and we checked it only against our own checks, not the wider test suite.
Have a bug like this one?
Describe the problem in a few lines. An engineer replies, and we agree the scope together.
Discuss a verification problem