.. | .. |
---|
19 | 19 | * means the userland is reading). |
---|
20 | 20 | */ |
---|
21 | 21 | #define UFFD_API ((__u64)0xAA) |
---|
22 | | -#define UFFD_API_FEATURES (UFFD_FEATURE_EVENT_FORK | \ |
---|
| 22 | +#define UFFD_API_REGISTER_MODES (UFFDIO_REGISTER_MODE_MISSING | \ |
---|
| 23 | + UFFDIO_REGISTER_MODE_WP | \ |
---|
| 24 | + UFFDIO_REGISTER_MODE_MINOR) |
---|
| 25 | +#define UFFD_API_FEATURES (UFFD_FEATURE_PAGEFAULT_FLAG_WP | \ |
---|
| 26 | + UFFD_FEATURE_EVENT_FORK | \ |
---|
23 | 27 | UFFD_FEATURE_EVENT_REMAP | \ |
---|
24 | | - UFFD_FEATURE_EVENT_REMOVE | \ |
---|
| 28 | + UFFD_FEATURE_EVENT_REMOVE | \ |
---|
25 | 29 | UFFD_FEATURE_EVENT_UNMAP | \ |
---|
26 | 30 | UFFD_FEATURE_MISSING_HUGETLBFS | \ |
---|
27 | 31 | UFFD_FEATURE_MISSING_SHMEM | \ |
---|
28 | 32 | UFFD_FEATURE_SIGBUS | \ |
---|
29 | | - UFFD_FEATURE_THREAD_ID) |
---|
| 33 | + UFFD_FEATURE_THREAD_ID | \ |
---|
| 34 | + UFFD_FEATURE_MINOR_HUGETLBFS | \ |
---|
| 35 | + UFFD_FEATURE_MINOR_SHMEM) |
---|
30 | 36 | #define UFFD_API_IOCTLS \ |
---|
31 | 37 | ((__u64)1 << _UFFDIO_REGISTER | \ |
---|
32 | 38 | (__u64)1 << _UFFDIO_UNREGISTER | \ |
---|
.. | .. |
---|
34 | 40 | #define UFFD_API_RANGE_IOCTLS \ |
---|
35 | 41 | ((__u64)1 << _UFFDIO_WAKE | \ |
---|
36 | 42 | (__u64)1 << _UFFDIO_COPY | \ |
---|
37 | | - (__u64)1 << _UFFDIO_ZEROPAGE) |
---|
| 43 | + (__u64)1 << _UFFDIO_ZEROPAGE | \ |
---|
| 44 | + (__u64)1 << _UFFDIO_WRITEPROTECT | \ |
---|
| 45 | + (__u64)1 << _UFFDIO_CONTINUE) |
---|
38 | 46 | #define UFFD_API_RANGE_IOCTLS_BASIC \ |
---|
39 | 47 | ((__u64)1 << _UFFDIO_WAKE | \ |
---|
40 | | - (__u64)1 << _UFFDIO_COPY) |
---|
| 48 | + (__u64)1 << _UFFDIO_COPY | \ |
---|
| 49 | + (__u64)1 << _UFFDIO_CONTINUE) |
---|
41 | 50 | |
---|
42 | 51 | /* |
---|
43 | 52 | * Valid ioctl command number range with this API is from 0x00 to |
---|
.. | .. |
---|
52 | 61 | #define _UFFDIO_WAKE (0x02) |
---|
53 | 62 | #define _UFFDIO_COPY (0x03) |
---|
54 | 63 | #define _UFFDIO_ZEROPAGE (0x04) |
---|
| 64 | +#define _UFFDIO_WRITEPROTECT (0x06) |
---|
| 65 | +#define _UFFDIO_CONTINUE (0x07) |
---|
55 | 66 | #define _UFFDIO_API (0x3F) |
---|
56 | 67 | |
---|
57 | 68 | /* userfaultfd ioctl ids */ |
---|
.. | .. |
---|
68 | 79 | struct uffdio_copy) |
---|
69 | 80 | #define UFFDIO_ZEROPAGE _IOWR(UFFDIO, _UFFDIO_ZEROPAGE, \ |
---|
70 | 81 | struct uffdio_zeropage) |
---|
| 82 | +#define UFFDIO_WRITEPROTECT _IOWR(UFFDIO, _UFFDIO_WRITEPROTECT, \ |
---|
| 83 | + struct uffdio_writeprotect) |
---|
| 84 | +#define UFFDIO_CONTINUE _IOWR(UFFDIO, _UFFDIO_CONTINUE, \ |
---|
| 85 | + struct uffdio_continue) |
---|
71 | 86 | |
---|
72 | 87 | /* read() structure */ |
---|
73 | 88 | struct uffd_msg { |
---|
.. | .. |
---|
122 | 137 | /* flags for UFFD_EVENT_PAGEFAULT */ |
---|
123 | 138 | #define UFFD_PAGEFAULT_FLAG_WRITE (1<<0) /* If this was a write fault */ |
---|
124 | 139 | #define UFFD_PAGEFAULT_FLAG_WP (1<<1) /* If reason is VM_UFFD_WP */ |
---|
| 140 | +#define UFFD_PAGEFAULT_FLAG_MINOR (1<<2) /* If reason is VM_UFFD_MINOR */ |
---|
125 | 141 | |
---|
126 | 142 | struct uffdio_api { |
---|
127 | 143 | /* userland asks for an API number and the features to enable */ |
---|
.. | .. |
---|
166 | 182 | * |
---|
167 | 183 | * UFFD_FEATURE_THREAD_ID pid of the page faulted task_struct will |
---|
168 | 184 | * be returned, if feature is not requested 0 will be returned. |
---|
| 185 | + * |
---|
| 186 | + * UFFD_FEATURE_MINOR_HUGETLBFS indicates that minor faults |
---|
| 187 | + * can be intercepted (via REGISTER_MODE_MINOR) for |
---|
| 188 | + * hugetlbfs-backed pages. |
---|
| 189 | + * |
---|
| 190 | + * UFFD_FEATURE_MINOR_SHMEM indicates the same support as |
---|
| 191 | + * UFFD_FEATURE_MINOR_HUGETLBFS, but for shmem-backed pages instead. |
---|
169 | 192 | */ |
---|
170 | 193 | #define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0) |
---|
171 | 194 | #define UFFD_FEATURE_EVENT_FORK (1<<1) |
---|
.. | .. |
---|
176 | 199 | #define UFFD_FEATURE_EVENT_UNMAP (1<<6) |
---|
177 | 200 | #define UFFD_FEATURE_SIGBUS (1<<7) |
---|
178 | 201 | #define UFFD_FEATURE_THREAD_ID (1<<8) |
---|
| 202 | +#define UFFD_FEATURE_MINOR_HUGETLBFS (1<<9) |
---|
| 203 | +#define UFFD_FEATURE_MINOR_SHMEM (1<<10) |
---|
179 | 204 | __u64 features; |
---|
180 | 205 | |
---|
181 | 206 | __u64 ioctls; |
---|
.. | .. |
---|
190 | 215 | struct uffdio_range range; |
---|
191 | 216 | #define UFFDIO_REGISTER_MODE_MISSING ((__u64)1<<0) |
---|
192 | 217 | #define UFFDIO_REGISTER_MODE_WP ((__u64)1<<1) |
---|
| 218 | +#define UFFDIO_REGISTER_MODE_MINOR ((__u64)1<<2) |
---|
193 | 219 | __u64 mode; |
---|
194 | 220 | |
---|
195 | 221 | /* |
---|
.. | .. |
---|
203 | 229 | __u64 dst; |
---|
204 | 230 | __u64 src; |
---|
205 | 231 | __u64 len; |
---|
206 | | - /* |
---|
207 | | - * There will be a wrprotection flag later that allows to map |
---|
208 | | - * pages wrprotected on the fly. And such a flag will be |
---|
209 | | - * available if the wrprotection ioctl are implemented for the |
---|
210 | | - * range according to the uffdio_register.ioctls. |
---|
211 | | - */ |
---|
212 | 232 | #define UFFDIO_COPY_MODE_DONTWAKE ((__u64)1<<0) |
---|
| 233 | + /* |
---|
| 234 | + * UFFDIO_COPY_MODE_WP will map the page write protected on |
---|
| 235 | + * the fly. UFFDIO_COPY_MODE_WP is available only if the |
---|
| 236 | + * write protected ioctl is implemented for the range |
---|
| 237 | + * according to the uffdio_register.ioctls. |
---|
| 238 | + */ |
---|
| 239 | +#define UFFDIO_COPY_MODE_WP ((__u64)1<<1) |
---|
213 | 240 | __u64 mode; |
---|
214 | 241 | |
---|
215 | 242 | /* |
---|
.. | .. |
---|
231 | 258 | __s64 zeropage; |
---|
232 | 259 | }; |
---|
233 | 260 | |
---|
| 261 | +struct uffdio_writeprotect { |
---|
| 262 | + struct uffdio_range range; |
---|
| 263 | +/* |
---|
| 264 | + * UFFDIO_WRITEPROTECT_MODE_WP: set the flag to write protect a range, |
---|
| 265 | + * unset the flag to undo protection of a range which was previously |
---|
| 266 | + * write protected. |
---|
| 267 | + * |
---|
| 268 | + * UFFDIO_WRITEPROTECT_MODE_DONTWAKE: set the flag to avoid waking up |
---|
| 269 | + * any wait thread after the operation succeeds. |
---|
| 270 | + * |
---|
| 271 | + * NOTE: Write protecting a region (WP=1) is unrelated to page faults, |
---|
| 272 | + * therefore DONTWAKE flag is meaningless with WP=1. Removing write |
---|
| 273 | + * protection (WP=0) in response to a page fault wakes the faulting |
---|
| 274 | + * task unless DONTWAKE is set. |
---|
| 275 | + */ |
---|
| 276 | +#define UFFDIO_WRITEPROTECT_MODE_WP ((__u64)1<<0) |
---|
| 277 | +#define UFFDIO_WRITEPROTECT_MODE_DONTWAKE ((__u64)1<<1) |
---|
| 278 | + __u64 mode; |
---|
| 279 | +}; |
---|
| 280 | + |
---|
| 281 | +struct uffdio_continue { |
---|
| 282 | + struct uffdio_range range; |
---|
| 283 | +#define UFFDIO_CONTINUE_MODE_DONTWAKE ((__u64)1<<0) |
---|
| 284 | + __u64 mode; |
---|
| 285 | + |
---|
| 286 | + /* |
---|
| 287 | + * Fields below here are written by the ioctl and must be at the end: |
---|
| 288 | + * the copy_from_user will not read past here. |
---|
| 289 | + */ |
---|
| 290 | + __s64 mapped; |
---|
| 291 | +}; |
---|
| 292 | + |
---|
| 293 | +/* |
---|
| 294 | + * Flags for the userfaultfd(2) system call itself. |
---|
| 295 | + */ |
---|
| 296 | + |
---|
| 297 | +/* |
---|
| 298 | + * Create a userfaultfd that can handle page faults only in user mode. |
---|
| 299 | + */ |
---|
| 300 | +#define UFFD_USER_MODE_ONLY 1 |
---|
| 301 | + |
---|
234 | 302 | #endif /* _LINUX_USERFAULTFD_H */ |
---|