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

mte/mpte apply only to breakpoint traps #723

Merged
merged 2 commits into from
May 11, 2022
Merged

mte/mpte apply only to breakpoint traps #723

merged 2 commits into from
May 11, 2022

Conversation

timsifive
Copy link
Contributor

This makes it possible to use triggers to debug some of the exception
handling code as well.

See 2022 email subject:"trigger questions"

This makes it possible to use triggers to debug some of the exception
handling code as well.

See 2022 email subject:"trigger questions"
@pdonahue-ventana
Copy link
Collaborator

This seems like it's not backwards compatible. I think that a note should be added to 1.2.1.5.

@timsifive
Copy link
Contributor Author

Huh. I'd written that but not pushed it up yet. Here it is.

Copy link
Collaborator

@pdonahue-ventana pdonahue-ventana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

@timsifive timsifive merged commit 4c0859b into master May 11, 2022
@timsifive timsifive deleted the tcontrol_trap branch May 11, 2022 14:00
@timsifive
Copy link
Contributor Author

The e-mail thread about this really starts at https://lists.riscv.org/g/tech-debug/topic/89848254#691.

This change solves some problems when stepping into exception handlers when native debugging the highest privilege mode. (This is really the ideal use case for external debug, but we try to accommodate native debugging here as well.) If every trap into M-Mode clears mte, then you can't use icount triggers to step into an exception handler. By limiting this clearing to breakpoint exceptions only, more code can be debugged.

@timsifive
Copy link
Contributor Author

AR feedback is that this change results in the mechanism not serving its purpose when non-breakpoint traps occur.

That sounds right to me. 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 can you look this over? You have a gift for corner cases.

timsifive added a commit that referenced this pull request Sep 19, 2023
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.
timsifive added a commit that referenced this pull request Sep 19, 2023
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.
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