rars icon indicating copy to clipboard operation
rars copied to clipboard

Delegate exceptions based on medeleg

Open mtvec opened this issue 5 years ago • 2 comments

This PR implements exception delegation based on medeleg as well as a UI setting to either delegate all or no exceptions.

This fixes #96

mtvec avatar Nov 08 '20 12:11 mtvec

Thanks for taking a stab at implementing this.

Some minor problems:

  • medeleg doesn't have any hint text.
  • trying to read medeleg should throw an illegal instruction exception
    • This might merit a new type of register that is only viewable/modifiable from GUI / internal code.
    • It might be interesting to have medeleg just not reset its value and remove the setting.
  • ecall (only if there is a valid system call) and ebreak bypass the normal exception trap handler.

Additionally I think the handling of exception traps is incorrect in two ways:

  • If utvec = 0, the normal error message should not be used. Instead it should either enter a tight loop or output a message about the trap handler address being invalid.
  • It should not set UPIE = 1. Instead it should set UPIE = UIE.

The csr test would be unable to pass if the ecall issue were fixed. Neither default value of medeleg would let it detect invalid CSRs and actually signal completion.

TheThirdOne avatar Nov 11 '20 01:11 TheThirdOne

It seems like no progress is currently being made on this. I plan to address the problems myself.

I plan to make a new class of register that is only read/writeable internally and persists its value across assembly; medeleg will be an instance of this. I will also remove the setting for delegating everything; if you are using the GUI and want something delegated, just set the value manually once per startup. Support for changing medeleg from the CLI will be left for a later time. The automated tests can set medeleg to whatever is needed to correctly test behavior. ecall and ebreak correctness will also be left for a later time. I plan to fix the exception handling issues and hint text issues.

TheThirdOne avatar Nov 24 '20 04:11 TheThirdOne

It seems like no progress is currently being made on this. I plan to address the problems myself.

Apologies, I somehow completely lost track of this and only noticed your responses now. Since you are going to address this yourself, I will close this PR.

mtvec avatar Sep 13 '23 06:09 mtvec