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

[CHERI-RISC-V] Restrict CToPtr and CFromPtr usage to ISAv8 compatibility #711

Closed
wants to merge 2 commits into from

Conversation

arichardson
Copy link
Member

See individual commits for more detailed descriptions.

@arichardson arichardson requested review from jrtc27 and bsdjhb July 7, 2023 00:22
CToPtr will be removed from the CHERI-RISC-V ISA in the future and will
not be part of a standardized version. We emit a branch-less form of
`x.tag ? x.addr - auth.base : 0` when we see the intrinsic in non-ISAv8
compilation mode instead.

When expanding `ptrtoint` in hybrid mode we also no longer subtract the
base of DDC as part of the expansion, since DDC relocation is no longer
part of xcherimin, and subtracting the base would result in an integer
that points to a different address when dereferenced.
We emit `x == 0 ? null : CSetOffset(auth, x)` when we see the intrinsic in
non-ISAv8 compilation mode instead. When expanding `inttoptr` in hybrid
mode, we do not include the base of DDC as part of the expansion (since
DDC relocation is no longer part of ISAv9). Adding the base would result
in a capability that points to a different address when dereferenced.
Therefore, inttoptr is expanded to `x == 0 ? null : CSetAddr(DDC, x)`.
It would be nice if we could just use `CSetAddr(DDC, x)` unconditionally
for non-constant arguments, but that could result in semantic differences
(tagged vs untagged) for integers that happen to be zero at run time.
@bsdjhb
Copy link
Contributor

bsdjhb commented Jul 7, 2023

Do we want to add a deprecation warning to the intrinsics perhaps so that we can eventually drop them (or have them only be valid when you have the underlying instructions)?

@arichardson
Copy link
Member Author

Closing this in favour of #708

@arichardson arichardson closed this Jul 7, 2023
@arichardson arichardson deleted the cheri-v9-drop-ctoptr-cfromptr branch July 7, 2023 21:24
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.

2 participants