of the faulting process to avoid memory corruption.
Starting from Linux 4.11,
-userfaultfd may notify the fault-handling threads about changes
+userfaultfd can also notify the fault-handling threads about changes
in the virtual memory layout of the faulting process.
In addition, if the faulting process invokes
-.BR fork (2)
-system call,
+.BR fork (2),
the userfaultfd objects associated with the parent may be duplicated
into the child process and the userfaultfd monitor will be notified
about the file descriptor associated with the userfault objects
Up to Linux 4.11,
userfaultfd can be used only with anonymous private memory mappings.
-
Since Linux 4.11,
userfaultfd can be also used with hugetlbfs and shared memory mappings.
.nf
.in +4n
struct uffd_msg {
- __u8 event; /* Type of event */
+ __u8 event; /* Type of event */
...
union {
struct {
- __u64 flags; /* Flags describing fault */
- __u64 address; /* Faulting address */
+ __u64 flags; /* Flags describing fault */
+ __u64 address; /* Faulting address */
} pagefault;
- struct {
- __u32 ufd; /* userfault file descriptor
- of the child process */
- } fork; /* since Linux 4.11 */
- struct {
- __u64 from; /* old address of the
- remapped area */
- __u64 to; /* new address of the
- remapped area */
- __u64 len; /* original mapping length */
- } remap; /* since Linux 4.11 */
- struct {
- __u64 start; /* start address of the
- removed area */
- __u64 end; /* end address of the
- removed area */
- } remove; /* since Linux 4.11 */
+
+ struct { /* Since Linux 4.11 */
+ __u32 ufd; /* Userfault file descriptor
+ of the child process */
+ } fork;
+
+ struct { /* Since Linux 4.11 */
+ __u64 from; /* Old address of remapped area */
+ __u64 to; /* New address of remapped area */
+ __u64 len; /* Original mapping length */
+ } remap;
+
+ struct { /* Since Linux 4.11 */
+ __u64 start; /* Start address of removed area */
+ __u64 end; /* End address of removed area */
+ } remove;
...
} arg;
.TP
.BR UFFD_EVENT_FORK " (since Linux 4.11)"
Generated when the faulting process invokes
-.BR fork (2)
-system call.
+.BR fork (2).
The event details are available in the
.I fork
field.
.TP
.BR UFFD_EVENT_REMAP " (since Linux 4.11)"
Generated when the faulting process invokes
-.BR mremap (2)
-system call.
+.BR mremap (2).
The event details are available in the
.I remap
field.
.BR UFFD_EVENT_REMOVE " (since Linux 4.11)"
Generated when the faulting process invokes
.BR madvise (2)
-system call with
+with
.BR MADV_DONTNEED
or
.BR MADV_REMOVE
Generated when the faulting process unmaps a memory range,
either explicitly using
.BR munmap (2)
-system call or implicitly during
+or implicitly during
.BR mmap (2)
or
-.BR mremap (2)
-system calls.
+.BR mremap (2).
The event details are available in the
.I remove
field.