Add support for UFFDIO_CONTINUE and UFFDIO_REGISTER_MODE_MINOR#72
Merged
bchalios merged 4 commits intobytecodealliance:mainfrom Aug 18, 2025
Merged
Add support for UFFDIO_CONTINUE and UFFDIO_REGISTER_MODE_MINOR#72bchalios merged 4 commits intobytecodealliance:mainfrom
bchalios merged 4 commits intobytecodealliance:mainfrom
Conversation
4 tasks
bchalios
requested changes
Aug 18, 2025
Collaborator
|
@roypat Other than the commit message fix above LGTM. Thanks for the refactoring on the exports. Cool stuff! |
1683154 to
0432458
Compare
This ioctl was only added in linux 5.7 [1], so remove the bindings for the ioctl number from the 4_11 and 4_14 features. The actual writeprotect functionality was already gated behind the linux5_7 feature. [1]: https://man7.org/linux/man-pages/man2/UFFDIO_WRITEPROTECT.2const.html Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
Extend the "constants are correct" tests to also cover the writeprotect related constants. Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
Change the linux{major}_{minor} files that contain handwritten
bindings for constants that bindgen doesnt understand to be
"incremental" (e.g. linux4_14 only contains constants that are new to
4_14 and just reexports the 4_11 constants for old ones), to avoid
redefining an ever increasing set of constants with each version.
Also adjust the test that checks the api features and available ioctl
constants to only verify that the rust-defined set of features is a
subset of the kernel available features. For example running the test
on a 6.8 host kernel with the 5.7 feature means the kernel has more
features than the uffd crate supports, but this does not mean that the
crate definitions are _wrong_, just that they are incomplete.
Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
With Linux 5.13, uffd got support for minor page fault notifications (e.g. a page was already in the page cache, but not present in the userspace page tables). Notifications are enabled by registering with UFFDIO_REGISTER_MODE_MINOR, and resolved via the UFFDIO_CONTINUE ioctl. Add support for these in userfaultfd-sys, as well as utility wrappers in the main crate. Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
0432458 to
6902c27
Compare
bchalios
approved these changes
Aug 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With Linux 5.13, UFFD got support for intercepting minor faults (e.g. where the page to be faulted in is present in the page cache, and only the userspace page table entries need to be established). This was realized by adding a new mode,
MODE_MINOR, upon which the uffd will receive events withUFFD_PAGEFAULT_FLAG_MINORset. These can then be resolved by issuing theUFFDIO_CONTINUEioctl, which operates almost exactly likeUFFDIO_COPY, expect that it doesnt do any memory population (since for minor faults, the memory contents are already there, in the page cache).Since this adds a new linux version based feature flag to userfaultfd-sys (and thus userfaultfd), I added some preliminary commits to try to avoid having to duplicate the ever-increasing number of uffd-related constants into yet another file, but if that's not wanted, am also happy to drop those.