mret during debug mode is incrementing minstret
Created by: silabs-oysteink
The E40P, E40X and E40S all jump to the debug exception handler if an mret is executed while in debug mode. The debug spec specifies 'undefined' behavior of this scenario.
For the X and S (I haven't checked E40P), this means that the instruction is not marked as illegal, and thus will increment minstret when it completes. In addition, the jump to the debug exception handler is performed when the mret is in the ID stage, as opposed to all other exceptions being taken from the WB stage.
A proposed fix is to mark the mret during debug mode as illegal in the decoder, and let it reach WB before the jump to the debug exception handler is taken. This will also avoid incrementing minstret as it is marked as illegal. Taking all exceptions from WB is more consistent and also simplifies how RVFI currently handles exceptions.
The proposed fix does however generate a mismatch with the ISS due to the E40X no longer incrementing minstret on an mret during debug.
This would also solve issue #458 (closed).
@eroom1966
: It seems like ISS is incrementing minstret for mret during debug, can you confirm this? This proposed RTL change would also need a similar change in the ISS after we update the user manual and make a new revision.