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

cuse(4): COMPAT_FREEBSD64 support #2238

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Conversation

bukinr
Copy link
Member

@bukinr bukinr commented Oct 22, 2024

Add COMPAT_FREEBSD64 needed for webcamd(8).

@@ -1133,7 +1149,18 @@ cuse_server_ioctl(struct cdev *dev, unsigned long cmd,

pccmd->entered = curthread;

*pcmd = pccmd->sub;
#ifdef COMPAT_FREEBSD64
if (!SV_CURPROC_FLAG(SV_CHERI)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this up to between lines 1129 and 1130, then you don't need to check the ABI, you can just use the ioctl to determine it. Checking the ABI should only be done when the ioctls have the same encoding for both.

#ifdef COMPAT_FREEBSD64
if (!SV_CURPROC_FLAG(SV_CHERI)) {
pcmd64 = (struct cuse_command64 *)data;
pcmd64->dev = (uint64_t)pccmd->sub.dev;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When building a hybrid kernel, cc complains about a missing __cheri_addr qualifier here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just use a uintptr_t cast instead of a uint64_t cast and then it will DTRT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have PTROUT for this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm although that's using uintptr_t not uintcap_t (and you want the latter, as the former will be the same as uint64_t for hybrid kernels...)

pcmd64->dev = (uint64_t)pccmd->sub.dev;
CP(pccmd->sub, *pcmd64, fflags);
CP(pccmd->sub, *pcmd64, per_file_handle);
CP(pccmd->sub, *pcmd64, data_pointer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per_file_handle and data_pointer are capabilities as well, presumably these assignments also want casts with __cheri_addr?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uintcap_t doesn't need such annotations, it's always address rather than offset

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.

4 participants