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

__builtin_cheri_cap_build is not polymorphic on the return type #730

Closed
kevin-brodsky-arm opened this issue Mar 1, 2024 · 3 comments
Closed

Comments

@kevin-brodsky-arm
Copy link

Unlike other similar CHERI builtins, __builtin_cheri_cap_build always returns void * __capability, even if passed uintcap_t: https://cheri-compiler-explorer.cl.cam.ac.uk/z/x5s45M

@arichardson
Copy link
Member

I believe my initial implementation of overloading the intrinsics had that feature, but after discussing with @jrtc27 we decided to have __builtin_cheri_cap_build always return a void *, but TBH I can't remember exactly why. I believe the rationale was that you should only be using buildcap to add a tag to some raw bit pattern (which cannot be a valid pointer by definition).

Things get a little bit ambiguous when using buildcap is used for unsealing, in which case you could have a tagged input argument.

@jrtc27
Copy link
Member

jrtc27 commented Mar 2, 2024

The point is the input is a raw bag of bits that shouldn't be a valid pointer and certainly shouldn't be a valid typed pointer, so is always a uintcap_t. The type of the authorising capability is also not meaningful when it comes to the output. So there's no input type to propagate to the output, which means you get a void * __capability.

@kevin-brodsky-arm
Copy link
Author

Ah fair enough, I agree that the input should always be uintcap_t, so indeed type propagation doesn't really work there.

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

3 participants