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

Xtval capability index on ASR exception for RISC-V #118

Open
andresag01 opened this issue Oct 5, 2023 · 1 comment
Open

Xtval capability index on ASR exception for RISC-V #118

andresag01 opened this issue Oct 5, 2023 · 1 comment

Comments

@andresag01
Copy link

The Sail implementation of CSpecialRW checks that the ASR permission is set in PCC when accessing select CSRs/SCRs:

} else if (needASR & not(pcc_access_system_regs())) then {
  handle_cheri_cap_exception(CapEx_AccessSystemRegsViolation, 0b1 @ scr);
  RETIRE_FAIL
} else {

According to line 2 above, the “register” index written to Xtval is 0b1 @ scr when the ASR check fails. This is really strange for a a few reasons:

  • The register index in Xtval is normally the register with the authorising capability that failed a check; 0b1 @ scr is something else!
  • I was assuming the return value for ASR exceptions for the RISC-V CSR instructions is always PCC because that is the authorising capability. In any case, we would need 12 bits to encode into Xtval in this case if we were to follow the same pattern, but I think only some 5 bits are currently allocated to the register index.

Ideally we would make CSpecialRW also output PCC in ASR trap.

@arichardson
Copy link
Member

I agree that this seems like a bug, PCC is the authorizing capability for this instruction so should be reported in tval.

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

No branches or pull requests

2 participants