UFFDIO_REGISTER - register a memory address range with the userfaultfd object
Contents
Description
Register a memory address range with the userfaultfd object. The pages in the range must be
“compatible”. Please refer to the list of register modes below for the compatible memory backends for
each mode.
The argp->range field defines a memory range starting at argp->range.start and continuing for
argp->range.len bytes that should be handled by the userfaultfd.
The argp->mode field defines the mode of operation desired for this memory region. The following values
may be bitwise ORed to set the userfaultfd mode for the specified range:
UFFDIO_REGISTER_MODE_MISSING
Track page faults on missing pages. Since Linux 4.3, only private anonymous ranges are
compatible. Since Linux 4.11, hugetlbfs and shared memory ranges are also compatible.
UFFDIO_REGISTER_MODE_WP
Track page faults on write-protected pages. Since Linux 5.7, only private anonymous ranges are
compatible.
UFFDIO_REGISTER_MODE_MINOR
Track minor page faults. Since Linux 5.13, only hugetlbfs ranges are compatible. Since Linux
5.14, compatibility with shmem ranges was added.
If the operation is successful, the kernel modifies the argp->ioctls bit-mask field to indicate which
ioctl(2) operations are available for the specified range. This returned bit mask can contain the
following bits:
1<<_UFFDIO_COPY
The UFFDIO_COPY operation is supported.
1<<_UFFDIO_WAKE
The UFFDIO_WAKE operation is supported.
1<<_UFFDIO_WRITEPROTECT
The UFFDIO_WRITEPROTECT operation is supported.
1<<_UFFDIO_ZEROPAGE
The UFFDIO_ZEROPAGE operation is supported.
1<<_UFFDIO_CONTINUE
The UFFDIO_CONTINUE operation is supported.
1<<_UFFDIO_POISON
The UFFDIO_POISON operation is supported.
Errors
EBUSY A mapping in the specified range is registered with another userfaultfd object.
EFAULTargp refers to an address that is outside the calling process's accessible address space.
EINVAL An invalid or unsupported bit was specified in the mode field; or the mode field was zero.
EINVAL There is no mapping in the specified address range.
EINVALrange.start or range.len is not a multiple of the system page size; or, range.len is zero; or
these fields are otherwise invalid.
EINVAL There as an incompatible mapping in the specified address range.
Examples
See userfaultfd(2).
History
Linux 4.3.
Library
Standard C library (libc, -lc)
Name
UFFDIO_REGISTER - register a memory address range with the userfaultfd object
Return Value
On success, 0 is returned. On error, -1 is returned and errno is set to indicate the error.
See Also
ioctl(2), ioctl_userfaultfd(2), UFFDIO_UNREGISTER(2const), userfaultfd(2)
linux.git/Documentation/admin-guide/mm/userfaultfd.rst
Linux man-pages 6.9.1 2024-06-17 UFFDIO_REGISTER(2const)
Standards
Linux.
Synopsis
#include<linux/userfaultfd.h> /* Definition of UFFD* constants */
#include<sys/ioctl.h>intioctl(intfd,UFFDIO_REGISTER,structuffdio_register*argp);#include<linux/userfaultfd.h>structuffdio_range{__u64start; /* Start of range */
__u64len; /* Length of range (bytes) */
};structuffdio_register{structuffdio_rangerange;__u64mode; /* Desired mode of operation (input) */
__u64ioctls; /* Available ioctl()s (output) */
};
