Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 28, 2023

Conversation

timsifive
Copy link
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
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 timsifive merged commit f9e5222 into master Sep 28, 2023
@timsifive timsifive deleted the tcontrol branch September 28, 2023 21:43
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