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

Add support for CheriBSD #55

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

arichardson
Copy link
Contributor

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.

This supersedes #36 and all the commits in that PR have been split out into separate changes.

Depends on CTSRD-CHERI/cheribsd#2194

This avoids a warning when building for CheriBSD (Morello purecap).
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.
…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. To avoid this problem this commit uses a new
`vfcntl` libc function (CTSRD-CHERI/cheribsd#2194),
that takes a va_list instead of variadic arguments.

Since this needs a new HAVE_VCNTL compile-time check, this adds a new
config.h header that also includes the HAVE_TIMERFD value. This removes
the need to pass -D flags on the command line.

This reduces the number of test failures on CheriBSD Morello from 210
to 8.
@arichardson arichardson marked this pull request as draft August 30, 2024 06:59
@arichardson
Copy link
Contributor Author

Marking as draft while I work on https://reviews.freebsd.org/D46403

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.

1 participant