-
Notifications
You must be signed in to change notification settings - Fork 5
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
Baremetal support #42
Baremetal support #42
Conversation
clang/lib/Baremetal/CMakeLists.txt
Outdated
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.
Do we need a separate directory for Baremetal? The only change seems to be redefining _cheri*. And that is already protected by the CHERIOT_BAREMETAL macro. The compilation path could be the same as CHERIoT's default, except for using CCalls instead of CHERI_CCalls.
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.
No, the clang headers are expected to work in all configurations. If we want clang to provide headers, we should fix the ones that clang provides to work with CHERIoT. I don't really want to do this, since we don't install the clang headers by default in the CHERIoT toolchain builds, I'd much rather that we change the RTOS headers to work with bare metal (which, I believe, requires a trivial change in cdefs.h
to define the __cheri_libcalls
and __cheri_compartment
macros to nothing when in bare-metal mode.
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.
I removed the baremetal subdir. I think it's a bad idea to tie baremetal compilation to cheriot-rtos (e.g. there are other potential os's that might be used with the toolchain). But I'm also not thrilled that install-baremetal-headers and install-clang-resource-headers overlap though it should be a noop (unless something depends on the file mod times).
I can remove the reach-over includes and just require the toolchain user install clang-resource-headers to get them.
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.
Removed headers for now based on private discussion.
cf4caa5
to
54a113f
Compare
47326ab
to
b5095ac
Compare
Adds -mabi=cheriot-baremetal to support code that is to run before the CHERIoT loader runs and sets up compartments and the like. This assumes the user will handle processing the root capability, any capability relocation necessary, and all code runs in a single compartment. - builtin intrinsics use direct C calls (instead of __cheri_libcalls) - __cheri_libcalls are reduced to direct C calls (with a warning) - intrinsic memory op symbols (e.g. memcpy) are not mangled - (on debug builds) assertions guard against emitted code that violates baremetal assumptions (e.g. cross-compartment calls)
Global weak symbols can resolve to a Constant; guard against this.
2d1b60b
to
7c6b130
Compare
This is the baremetal support I'm using to build OpenTitan and OT-based applications (available at opensecura.googlesource.com). These are tested in simulation.
There are XXX comments that are reminders for me; will remove after resolving feedback.
Include files are derived from cheriot-rtos; I've preserved the copyright.