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

Clarify when mtvec.mode should be included in representability check #540

Open
tomaird opened this issue Feb 18, 2025 · 2 comments · May be fixed by #542
Open

Clarify when mtvec.mode should be included in representability check #540

tomaird opened this issue Feb 18, 2025 · 2 comments · May be fixed by #542

Comments

@tomaird
Copy link
Contributor

tomaird commented Feb 18, 2025

The description for mtvecc has the following:

Image

From these two highlighted sections, it's a bit unclear when writing to xtvecc whether the representability check should be done on

  1. mtvecc.address (including mode bits) - this is the address that is visible to SW
  2. OR {mtvecc.address[MXLEN-1:2], 2'b00} - this is the address that is actually jumped to (for non-vectored traps)
  3. OR both of the above

(Obviously when MODE=vectored we also do the representability check on {mtvecc.address[MXLEN-1:2], 2'b00} + 4 * HICAUSE - but that is more clear, since we're checking the maximum possible vector target is in range.)

@tariqkurd-repo
Copy link
Collaborator

tariqkurd-repo commented Feb 19, 2025

Yes - this is clearly wrong - the rep check where the MODE is set to Vectored has the LSBs set to 2'b01, but the address jumped to on exception always has the LSBs set to 2'b00.
In very weird cases, it's possible for the value in mtvecc to only be representable when the LSB is set.
Therefore we must be clear that the address range checked for representability must include all possible exception vector addresses.

@tariqkurd-repo tariqkurd-repo linked a pull request Feb 19, 2025 that will close this issue
@arichardson
Copy link
Collaborator

We also don't specify whether you can use a sentry in direct mode. I am not sure if this is something that should be supported by unsealing on trap (@jrtc27 @nwf)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants