-
Notifications
You must be signed in to change notification settings - Fork 48
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
Refine CHERI macro and feature definitions #763
base: dev
Are you sure you want to change the base?
Conversation
00f9977
to
4f38f04
Compare
This should probably be split into two changes, the backwards compatible changes to |
I do wonder if we want to use __has_feature(cheri) ? Capabilities seems rather generic and may be difficult to upstream |
I agree on that. It's rather confusing for systems like seL4 that already have their own notion/definition/types for a capability. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this is a major breaking change but I don't think there is much choice outside of cheribsd that uses it so LGTM if @jrtc27 is also happy with it
This is intended to replace __has_feature(capabilities) which is almost certainly too generic to upstream. We'll support them side by side for the long term in our tree, but projects should generally migrate to __has_feature(cheri) as their need for older compilers passes.
Migrate tests that aren't explicitly about __has_feature(capabilities) to __has_feature(cheri).
4f38f04
to
b374716
Compare
@@ -25,7 +25,7 @@ void* __capability x = 0; | |||
|
|||
#if defined(__CHERI__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a test for the new hybrid macro here? And maybe update the RUN lines for RISC-V instead of MIPS? But that can be done in a future commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the new change, LGTM. Will wait for @jrtc27 for merging though
This is meant to replace expressions like: __has_feature(capabilities) && !defined(__CHERI_PURE_CAPABILITY__) or (currently( __CHERI__ && !defined(__CHERI_PURE_CAPABILITY__)
WARNING: This is a breaking change for hybrid code bases. Rationale: We strongly encourage all CHERI consumers to use a pure-capability ABI whenever possible. Therefore it should be the easiest thing to type and less preferred options should be longer. The existing macros date to the earliest compiler support which barely supported capability types. Before broad adoption of CHERI we should make the macros be sensible. We're past Stuart Feldman's too many users of make to change the tabs threshold (12), but few codebases will be effected, the required changes are simple can be safely performed without automatic review, and we shouldn't have to live with this aspect of history forever. Backwards compatible code transition: For purecap + standard C/C++ code: No change required. For hybrid + standard C/C++ code: __CHERI__ -> __has_feature(capabilities) For mixed code: __CHERI__ -> __has_feature(capabilities) Once the need for compatability with old compilers is passed further simplication is possible. For purecap + standard C/C++ code: __CHERI_PURE_CAPABILITY__ -> __CHERI__ For hybrid + standard C/C++ code: __has_feature(capabilities) && !defined(__CHERI_PURE_CAPABILITY__) -> __CHERI_HYBRID__
b374716
to
da8608d
Compare
__CHERI__
mean purecap
I used to use
This assumes all projects have some sort of a global shared header where this could be defined, but unfortunately this is not always the case. Existing projects such as muslc [1], newlib, CHERI-Linux also still use |
Note that this set of changes will actually make the GCC world happier as you can just use |
And that change can be made now even if they want to support the older compiler versions. |
This set of changes does three main things:
__CHERI_HYBRID__
to indicate hybrid compilation__has_feature(cheri)
to eventually replace the overly generic__has_feature(capabilities)
__CHERI__
a synonym for__CHERI_PURE_CAPABILITY__
and adds an__CHERI_HYBRID__
This is a breaking changeRationale: We strongly encourage all CHERI consumers to use a pure-capability ABI whenever possible. Therefore it should be the easiest thing to type and less preferred options should be longer. The existing macros date to the earliest compiler support which barely supported capability types. Before broad adoption of CHERI we should make the macros be sensible. We're past Stuart Feldman's too many users of
make
to change the tabs threshold (12), but few codebases will be effected and the required changes are simple and can be safely performed automatically. We shouldn't have to live with this aspect of history forever.