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

Baremetal support #42

Merged
merged 2 commits into from
Oct 11, 2024
Merged

Conversation

sleffler
Copy link

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.

Copy link

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.

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.

Copy link
Author

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.

Copy link
Author

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.

@sleffler sleffler force-pushed the baremetal-abi branch 3 times, most recently from cf4caa5 to 54a113f Compare September 26, 2024 17:54
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.
@davidchisnall davidchisnall merged commit 3a9b8a5 into CHERIoT-Platform:cheriot Oct 11, 2024
1 check passed
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