-
Notifications
You must be signed in to change notification settings - Fork 24
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
Add support for CheriBSD #36
Conversation
The current version of epoll-shim does not work as a purecap library. Use my fork until jiixyj/epoll-shim#36 has been merged.
Thank you for this! Those changes look reasonable to me at a first glance. CheriBSD looks like a cool project! Is there a way for me to test it without a dev board? Is https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/cheri-qemu.html the way to go? |
Yes, QEMU is the best way to get started. If you clone cheribuild, running |
And there is of course a target to build epoll-shim as well, |
Friendly ping :) |
ping? |
Sorry to ping again, but would it be possible to merge this? |
ping? |
090f859
to
f780fb7
Compare
rebased on latest master, @jiixyj any chance this could be merged? |
ping? |
ping? It would be nice if we could drop the local patch from CheriBSD ports |
@jiixyj Any chance this could be merged? |
Thanks for your patience -- I haven't forgotten about this! Some thoughts:
|
When running the tests on a CheriBSD system on Arm Morello, pointers are 16 bytes, so the implicit size of 8192 bytes is not large enough to hold all of struct atf_tc_impl_s_ and running the tests fails with a bounds violation. To fix this issue, this commit explicitly sizes the array instead of relying on the alignment and adds a static assertion to the source file to ensure this invariant holds. I've also reordered struct atf_tc_impl_s_ to avoid padding on CHERI systems.
…ents `fcntl()` abuses C variadic arguments to implement optional parameters. We want to forward this argument to the real `fcntl()` call, but doing so is non-portable. On most architectures, we can just read an `intptr_t`/`void*` and this will give us a (semi-)valid result even if no argument/an int was passed instead since `va_arg()` will generally read the next argument register or arbitrary data from the stack. On CHERI-enabled architectures, variadic arguments are tightly bounded, which means that reading a `void*` if an `int` was passed will result in a runtime trap. This commit adds a switch ensures that we read the correct number of bytes from the variadic arguments. This ugly workaround would not be needed if a vfcntl() call taking a va_list existed, or if fcntl just took an intptr_t argument. This reduces the number of test failures on CheriBSD Morello from 210 to 8.
Some systems such as 64-bit CHERI-RISC-V or Arm Morello have 128-bit pointers, so for them the sizeof(event) assertion needs to be updated.
This avoids a warning when building for CheriBSD (Morello purecap).
Trying to run the test executables during the build to get the list of test cases causes my cross-compilation to fail. Skip adding the test cases to CTest in that case (but still build them we can run them manually).
Due to a bug in CheriBSD, errno was set non-zero when starting this test, but without these checks the test confusingly failed in the later check which made me think something was wrong in timerfd_create. Check errno on startup to make this more obvious. See CTSRD-CHERI/cheribsd#1424
f780fb7
to
ecac389
Compare
Sorry for the delay - I've rebased the changes. Unfortunately there is currently no way to interpose fcntl more easily... |
I tried running the tests on my Morello board and noticed that most of them were failing. This patch series makes epoll-shim work correctly when running on CheriBSD (a fork of FreeBSD that adds support for CHERI-enabled architectures such as CHERI-RISC-V and Arm Morello).
With this patch series all but two tests pass for me and the last remaining failures will go away once CTSRD-CHERI/cheribsd#1424 has been fixed.