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

Ensure GCPERM result is forwards-compatible with software #501

Merged
merged 1 commit into from
Feb 14, 2025

Conversation

arichardson
Copy link
Collaborator

@arichardson arichardson commented Jan 7, 2025

When new extensions add permissions that are subsets of current permissions
(e.g. Zcherilevels refines loads/stores), then a system that does not
support these permissions should still report ones in GCPERM to ensure that
code that inspects permissions knows that the load/store behaves as if all
of these permission bits were set.
We reserve the low 24 bits as ones (to be used as refinements of the current
permissions) and the upper 8 (40 for RV64) bits as zeros (to be used for
new permissions that aren't subsets (e.g. seal/unseal/compartment ID).

Partially addresses #502

@arichardson
Copy link
Collaborator Author

We could also report a hardcoded 1 here since not implementing the levels extension ensures that all loads/stores behave as if the permissions were always granted. But I think being able to easily detect whether the levels ext is implemented probably makes more sense?

@arichardson arichardson force-pushed the levels-clarification branch 2 times, most recently from 2b4bbb4 to 4d8e589 Compare January 7, 2025 19:59
@arichardson arichardson changed the title Clarify GCPERM result when the level extension is not implemented Clarify permissions when the level extension is not implemented Jan 7, 2025
@arichardson
Copy link
Collaborator Author

If we go for RES1 on GCPERM/ACPERM, does that mean we need to have all unused bits hardwired to one?

That would break patterns like gcperm(acperm(cap, REQUESTED_PERMS)) == REQUESTED_PERMS to check if you got exactly what you asked for.

@jrtc27
Copy link
Collaborator

jrtc27 commented Jan 10, 2025

These are all good questions that need to be thought through carefully, hence my repeated invitations to think about the problem (e.g. I mentioned this back in October 2023 on our internal Slack)...

@arichardson
Copy link
Collaborator Author

Updated to reserve bits 0-23 as 1 and 24-xlen-1 as zero in the GCPERM mask. Also added a note on how new permissions need to be allocated.

@arichardson arichardson requested a review from jrtc27 February 13, 2025 18:31
@arichardson arichardson changed the title Clarify permissions when the level extension is not implemented Ensure GCPERM result is forwards-compatible with software Feb 13, 2025
When new extensions add permissions that are subsets of current permissions
(e.g. Zcherilevels refines loads/stores), then a system that does not
support these permissions should still report ones in GCPERM to ensure that
code that inspects permissions knows that the load/store behaves as if all
of these permission bits were set.
We reserve the low 24 bits as ones (to be used as refinements of the current
permissions) and the upper 8 (40 for RV64) bits as zeros (to be used for
new permissions that aren't subsets (e.g. seal/unseal/compartment ID).

Partially addresses riscv#502
@arichardson
Copy link
Collaborator Author

Added note on ACPERM behaviour based on offline feedback from @LawrenceEsswood. This matches what was previously discussed in the CHERI meetings, so will merge this now. We can always adjust the number of reserved one bits during review.

@arichardson arichardson merged commit 4430526 into riscv:main Feb 14, 2025
2 checks passed
@arichardson arichardson deleted the levels-clarification branch February 14, 2025 02:01
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 this pull request may close these issues.

3 participants