UFFDIO_REGISTER − register a memory address range with the userfaultfd object
Standard C library (libc, −lc)
#include
<linux/userfaultfd.h> /* Definition of
UFFD* constants */
#include <sys/ioctl.h>
int ioctl(int fd, UFFDIO_REGISTER, struct uffdio_register *argp);
#include <linux/userfaultfd.h>
struct
uffdio_range {
__u64 start; /* Start of range */
__u64 len; /* Size of range (bytes) */
};
struct uffdio_register {
struct uffdio_range range;
__u64 mode; /* Desired mode of operation (input) */
__u64 ioctls; /* Available ioctl()s (output) */
};
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.
On success, 0 is returned. On error, −1 is returned and errno is set to indicate the error.
|
EBUSY |
A mapping in the specified range is registered with another userfaultfd object. | ||
|
EFAULT |
argp 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. | ||
|
EINVAL |
range.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. |
Linux.
Linux 4.3.
See userfaultfd(2).
ioctl(2), ioctl_userfaultfd(2), UFFDIO_UNREGISTER(2const), userfaultfd(2)
linux.git/Documentation/admin−guide/mm/userfaultfd.rst