Debian Codegraph @

upstream/debian-trixie/man2/UFFDIO_REGISTER.2const

raw
1 .\" Copyright 2016, IBM Corporation.
2 .\" Written by Mike Rapoport <[email protected]>
3 .\" Copyright 2016, Michael Kerrisk <[email protected]>
4 .\" Copyright 2024, Alejandro Colomar <[email protected]>
5 .\"
6 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\"
8 .TH UFFDIO_REGISTER 2const 2024-06-17 "Linux man-pages 6.9.1"
9 .SH NAME
10 UFFDIO_REGISTER
11 \-
12 register a memory address range with the userfaultfd object
13 .SH LIBRARY
14 Standard C library
15 .RI ( libc ", " \-lc )
16 .SH SYNOPSIS
17 .nf
18 .BR "#include <linux/userfaultfd.h>" " /* Definition of " UFFD* " constants */"
19 .B #include <sys/ioctl.h>
20 .P
21 .BI "int ioctl(int " fd ", UFFDIO_REGISTER, struct uffdio_register *" argp );
22 .P
23 .B #include <linux/userfaultfd.h>
24 .P
25 .fi
26 .EX
27 .B struct uffdio_range {
28 .BR " __u64 start;" " /* Start of range */"
29 .BR " __u64 len;" " /* Length of range (bytes) */"
30 .B };
31 \&
32 .B struct uffdio_register {
33 .B " struct uffdio_range range;"
34 .BR " __u64 mode;" " /* Desired mode of operation (input) */"
35 .BR " __u64 ioctls;" " /* Available ioctl()s (output) */"
36 .B };
37 .EE
38 .SH DESCRIPTION
39 Register a memory address range with the userfaultfd object.
40 The pages in the range must be \[lq]compatible\[rq].
41 Please refer to the list of register modes below
42 for the compatible memory backends for each mode.
43 .P
44 The
45 .I argp->range
46 field defines a memory range starting at
47 .I argp->range.start
48 and continuing for
49 .I argp->range.len
50 bytes that should be handled by the userfaultfd.
51 .P
52 The
53 .I argp->mode
54 field defines the mode of operation desired for this memory region.
55 The following values may be bitwise ORed to set the userfaultfd mode for
56 the specified range:
57 .TP
58 .B UFFDIO_REGISTER_MODE_MISSING
59 Track page faults on missing pages.
60 Since Linux 4.3,
61 only private anonymous ranges are compatible.
62 Since Linux 4.11,
63 hugetlbfs and shared memory ranges are also compatible.
64 .TP
65 .B UFFDIO_REGISTER_MODE_WP
66 Track page faults on write-protected pages.
67 Since Linux 5.7,
68 only private anonymous ranges are compatible.
69 .TP
70 .B UFFDIO_REGISTER_MODE_MINOR
71 Track minor page faults.
72 Since Linux 5.13,
73 only hugetlbfs ranges are compatible.
74 Since Linux 5.14,
75 compatibility with shmem ranges was added.
76 .P
77 If the operation is successful, the kernel modifies the
78 .I argp->ioctls
79 bit-mask field to indicate which
80 .BR ioctl (2)
81 operations are available for the specified range.
82 This returned bit mask can contain the following bits:
83 .TP
84 .B 1 << _UFFDIO_COPY
85 The
86 .B UFFDIO_COPY
87 operation is supported.
88 .TP
89 .B 1 << _UFFDIO_WAKE
90 The
91 .B UFFDIO_WAKE
92 operation is supported.
93 .TP
94 .B 1 << _UFFDIO_WRITEPROTECT
95 The
96 .B UFFDIO_WRITEPROTECT
97 operation is supported.
98 .TP
99 .B 1 << _UFFDIO_ZEROPAGE
100 The
101 .B UFFDIO_ZEROPAGE
102 operation is supported.
103 .TP
104 .B 1 << _UFFDIO_CONTINUE
105 The
106 .B UFFDIO_CONTINUE
107 operation is supported.
108 .TP
109 .B 1 << _UFFDIO_POISON
110 The
111 .B UFFDIO_POISON
112 operation is supported.
113 .SH RETURN VALUE
114 On success,
115 0 is returned.
116 On error, \-1 is returned and
117 .I errno
118 is set to indicate the error.
119 .SH ERRORS
120 .\" FIXME Is the following error list correct?
121 .\"
122 .TP
123 .B EBUSY
124 A mapping in the specified range is registered with another
125 userfaultfd object.
126 .TP
127 .B EFAULT
128 .I argp
129 refers to an address that is outside the calling process's
130 accessible address space.
131 .TP
132 .B EINVAL
133 An invalid or unsupported bit was specified in the
134 .I mode
135 field; or the
136 .I mode
137 field was zero.
138 .TP
139 .B EINVAL
140 There is no mapping in the specified address range.
141 .TP
142 .B EINVAL
143 .I range.start
144 or
145 .I range.len
146 is not a multiple of the system page size; or,
147 .I range.len
148 is zero; or these fields are otherwise invalid.
149 .TP
150 .B EINVAL
151 There as an incompatible mapping in the specified address range.
152 .\" Mike Rapoport:
153 .\" ENOMEM if the process is exiting and the
154 .\" mm_struct has gone by the time userfault grabs it.
155 .SH STANDARDS
156 Linux.
157 .SH HISTORY
158 Linux 4.3.
159 .SH EXAMPLES
160 See
161 .BR userfaultfd (2).
162 .SH SEE ALSO
163 .BR ioctl (2),
164 .BR ioctl_userfaultfd (2),
165 .BR UFFDIO_UNREGISTER (2const),
166 .BR userfaultfd (2)
167 .P
168 .I linux.git/\:Documentation/\:admin\-guide/\:mm/\:userfaultfd.rst