Skip to content

AR: tcontrol.mie applies to all traps, not just breakpoints#880

Merged
Tim Newsome (timsifive) merged 1 commit into
masterfrom
tcontrol
Sep 28, 2023
Merged

AR: tcontrol.mie applies to all traps, not just breakpoints#880
Tim Newsome (timsifive) merged 1 commit into
masterfrom
tcontrol

Conversation

@timsifive

Copy link
Copy Markdown
Contributor

Reverts #723, which would result in mepc etc. being clobbered if a breakpoint trigger would fire in the most privileged mode.

Specifically, consider:

  1. icount is set so that it'll trigger on the first instruction of an exception handler.
  2. Code takes an exception, saving mepc etc.
  3. Now icount fires causing a breakpoint exception, clobbering mepc.

Reverts #723, which would result in mepc etc. being clobbered if a
breakpoint trigger would fire in the most privileged mode.

Specifically, consider:
1. icount is set so that it'll trigger on the first instruction of an exception handler.
2. Code takes an exception, saving mepc etc.
3. Now icount fires causing a breakpoint exception, clobbering mepc.
@pdonahue-ventana

Copy link
Copy Markdown
Collaborator

This makes sense and it's kind of like the general mstatus.MIE and mstatus.MPIE behavior. When you enter M mode on any trap then you clear MIE and you can't take an interrupt until the handler has done whatever is necessary to reenter (e.g. push mepc on the stack) and then indicate that it has done so by setting MIE. Similarly, when you enter M mode on any trap, you clear mte and can't take a breakpoint until the handler has indicated it is ready by setting mte again.

It's too bad that you can't debug the handler but that's just a limitation, just like handlers have to avoid traps (no illegal instructions, no interrupts, no load/store that could page fault, etc.) during this early part of the handler. You can still debug handlers with an external debugger (which may be less convenient for someone who was hoping to not need to connect to JTAG but that's life).

@timsifive Tim Newsome (timsifive) merged commit f9e5222 into master Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants