1dd873966SEric Auger /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2c1fcf220SDr. David Alan Gilbert /* 3c1fcf220SDr. David Alan Gilbert * include/linux/userfaultfd.h 4c1fcf220SDr. David Alan Gilbert * 5c1fcf220SDr. David Alan Gilbert * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org> 6c1fcf220SDr. David Alan Gilbert * Copyright (C) 2015 Red Hat, Inc. 7c1fcf220SDr. David Alan Gilbert * 8c1fcf220SDr. David Alan Gilbert */ 9c1fcf220SDr. David Alan Gilbert 10c1fcf220SDr. David Alan Gilbert #ifndef _LINUX_USERFAULTFD_H 11c1fcf220SDr. David Alan Gilbert #define _LINUX_USERFAULTFD_H 12c1fcf220SDr. David Alan Gilbert 13c1fcf220SDr. David Alan Gilbert #include <linux/types.h> 14c1fcf220SDr. David Alan Gilbert 1593e0932bSPeter Xu /* ioctls for /dev/userfaultfd */ 1693e0932bSPeter Xu #define USERFAULTFD_IOC 0xAA 1793e0932bSPeter Xu #define USERFAULTFD_IOC_NEW _IO(USERFAULTFD_IOC, 0x00) 1893e0932bSPeter Xu 19c1fcf220SDr. David Alan Gilbert /* 203a5eb5b4SPaolo Bonzini * If the UFFDIO_API is upgraded someday, the UFFDIO_UNREGISTER and 213a5eb5b4SPaolo Bonzini * UFFDIO_WAKE ioctls should be defined as _IOW and not as _IOR. In 223a5eb5b4SPaolo Bonzini * userfaultfd.h we assumed the kernel was reading (instead _IOC_READ 233a5eb5b4SPaolo Bonzini * means the userland is reading). 24c1fcf220SDr. David Alan Gilbert */ 253a5eb5b4SPaolo Bonzini #define UFFD_API ((__u64)0xAA) 26278f064eSEduardo Habkost #define UFFD_API_REGISTER_MODES (UFFDIO_REGISTER_MODE_MISSING | \ 27278f064eSEduardo Habkost UFFDIO_REGISTER_MODE_WP | \ 28278f064eSEduardo Habkost UFFDIO_REGISTER_MODE_MINOR) 29dc6f8d45SCornelia Huck #define UFFD_API_FEATURES (UFFD_FEATURE_PAGEFAULT_FLAG_WP | \ 30dc6f8d45SCornelia Huck UFFD_FEATURE_EVENT_FORK | \ 313a5eb5b4SPaolo Bonzini UFFD_FEATURE_EVENT_REMAP | \ 3274c98e20SCornelia Huck UFFD_FEATURE_EVENT_REMOVE | \ 3374c98e20SCornelia Huck UFFD_FEATURE_EVENT_UNMAP | \ 343a5eb5b4SPaolo Bonzini UFFD_FEATURE_MISSING_HUGETLBFS | \ 35d4083f50SAlexey Perevalov UFFD_FEATURE_MISSING_SHMEM | \ 36d4083f50SAlexey Perevalov UFFD_FEATURE_SIGBUS | \ 37278f064eSEduardo Habkost UFFD_FEATURE_THREAD_ID | \ 38327d4b7fSBharata B Rao UFFD_FEATURE_MINOR_HUGETLBFS | \ 39e4082063SAlex Williamson UFFD_FEATURE_MINOR_SHMEM | \ 40d525f73fSChenyi Qiang UFFD_FEATURE_EXACT_ADDRESS | \ 41*d0bf492fSCédric Le Goater UFFD_FEATURE_WP_HUGETLBFS_SHMEM | \ 42*d0bf492fSCédric Le Goater UFFD_FEATURE_WP_UNPOPULATED) 43c1fcf220SDr. David Alan Gilbert #define UFFD_API_IOCTLS \ 44c1fcf220SDr. David Alan Gilbert ((__u64)1 << _UFFDIO_REGISTER | \ 45c1fcf220SDr. David Alan Gilbert (__u64)1 << _UFFDIO_UNREGISTER | \ 46c1fcf220SDr. David Alan Gilbert (__u64)1 << _UFFDIO_API) 47c1fcf220SDr. David Alan Gilbert #define UFFD_API_RANGE_IOCTLS \ 48c1fcf220SDr. David Alan Gilbert ((__u64)1 << _UFFDIO_WAKE | \ 49c1fcf220SDr. David Alan Gilbert (__u64)1 << _UFFDIO_COPY | \ 50dc6f8d45SCornelia Huck (__u64)1 << _UFFDIO_ZEROPAGE | \ 51278f064eSEduardo Habkost (__u64)1 << _UFFDIO_WRITEPROTECT | \ 52278f064eSEduardo Habkost (__u64)1 << _UFFDIO_CONTINUE) 533a5eb5b4SPaolo Bonzini #define UFFD_API_RANGE_IOCTLS_BASIC \ 543a5eb5b4SPaolo Bonzini ((__u64)1 << _UFFDIO_WAKE | \ 55278f064eSEduardo Habkost (__u64)1 << _UFFDIO_COPY | \ 56d525f73fSChenyi Qiang (__u64)1 << _UFFDIO_CONTINUE | \ 57d525f73fSChenyi Qiang (__u64)1 << _UFFDIO_WRITEPROTECT) 58c1fcf220SDr. David Alan Gilbert 59c1fcf220SDr. David Alan Gilbert /* 60c1fcf220SDr. David Alan Gilbert * Valid ioctl command number range with this API is from 0x00 to 61c1fcf220SDr. David Alan Gilbert * 0x3F. UFFDIO_API is the fixed number, everything else can be 62c1fcf220SDr. David Alan Gilbert * changed by implementing a different UFFD_API. If sticking to the 63c1fcf220SDr. David Alan Gilbert * same UFFD_API more ioctl can be added and userland will be aware of 64c1fcf220SDr. David Alan Gilbert * which ioctl the running kernel implements through the ioctl command 65c1fcf220SDr. David Alan Gilbert * bitmask written by the UFFDIO_API. 66c1fcf220SDr. David Alan Gilbert */ 67c1fcf220SDr. David Alan Gilbert #define _UFFDIO_REGISTER (0x00) 68c1fcf220SDr. David Alan Gilbert #define _UFFDIO_UNREGISTER (0x01) 69c1fcf220SDr. David Alan Gilbert #define _UFFDIO_WAKE (0x02) 70c1fcf220SDr. David Alan Gilbert #define _UFFDIO_COPY (0x03) 71c1fcf220SDr. David Alan Gilbert #define _UFFDIO_ZEROPAGE (0x04) 72dc6f8d45SCornelia Huck #define _UFFDIO_WRITEPROTECT (0x06) 73278f064eSEduardo Habkost #define _UFFDIO_CONTINUE (0x07) 74c1fcf220SDr. David Alan Gilbert #define _UFFDIO_API (0x3F) 75c1fcf220SDr. David Alan Gilbert 76c1fcf220SDr. David Alan Gilbert /* userfaultfd ioctl ids */ 77c1fcf220SDr. David Alan Gilbert #define UFFDIO 0xAA 78c1fcf220SDr. David Alan Gilbert #define UFFDIO_API _IOWR(UFFDIO, _UFFDIO_API, \ 79c1fcf220SDr. David Alan Gilbert struct uffdio_api) 80c1fcf220SDr. David Alan Gilbert #define UFFDIO_REGISTER _IOWR(UFFDIO, _UFFDIO_REGISTER, \ 81c1fcf220SDr. David Alan Gilbert struct uffdio_register) 82c1fcf220SDr. David Alan Gilbert #define UFFDIO_UNREGISTER _IOR(UFFDIO, _UFFDIO_UNREGISTER, \ 83c1fcf220SDr. David Alan Gilbert struct uffdio_range) 84c1fcf220SDr. David Alan Gilbert #define UFFDIO_WAKE _IOR(UFFDIO, _UFFDIO_WAKE, \ 85c1fcf220SDr. David Alan Gilbert struct uffdio_range) 86c1fcf220SDr. David Alan Gilbert #define UFFDIO_COPY _IOWR(UFFDIO, _UFFDIO_COPY, \ 87c1fcf220SDr. David Alan Gilbert struct uffdio_copy) 88c1fcf220SDr. David Alan Gilbert #define UFFDIO_ZEROPAGE _IOWR(UFFDIO, _UFFDIO_ZEROPAGE, \ 89c1fcf220SDr. David Alan Gilbert struct uffdio_zeropage) 90dc6f8d45SCornelia Huck #define UFFDIO_WRITEPROTECT _IOWR(UFFDIO, _UFFDIO_WRITEPROTECT, \ 91dc6f8d45SCornelia Huck struct uffdio_writeprotect) 92327d4b7fSBharata B Rao #define UFFDIO_CONTINUE _IOWR(UFFDIO, _UFFDIO_CONTINUE, \ 93278f064eSEduardo Habkost struct uffdio_continue) 94c1fcf220SDr. David Alan Gilbert 95c1fcf220SDr. David Alan Gilbert /* read() structure */ 96c1fcf220SDr. David Alan Gilbert struct uffd_msg { 97c1fcf220SDr. David Alan Gilbert __u8 event; 98c1fcf220SDr. David Alan Gilbert 99c1fcf220SDr. David Alan Gilbert __u8 reserved1; 100c1fcf220SDr. David Alan Gilbert __u16 reserved2; 101c1fcf220SDr. David Alan Gilbert __u32 reserved3; 102c1fcf220SDr. David Alan Gilbert 103c1fcf220SDr. David Alan Gilbert union { 104c1fcf220SDr. David Alan Gilbert struct { 105c1fcf220SDr. David Alan Gilbert __u64 flags; 106c1fcf220SDr. David Alan Gilbert __u64 address; 107d4083f50SAlexey Perevalov union { 108d4083f50SAlexey Perevalov __u32 ptid; 109d4083f50SAlexey Perevalov } feat; 110c1fcf220SDr. David Alan Gilbert } pagefault; 111c1fcf220SDr. David Alan Gilbert 112c1fcf220SDr. David Alan Gilbert struct { 1133a5eb5b4SPaolo Bonzini __u32 ufd; 1143a5eb5b4SPaolo Bonzini } fork; 1153a5eb5b4SPaolo Bonzini 1163a5eb5b4SPaolo Bonzini struct { 1173a5eb5b4SPaolo Bonzini __u64 from; 1183a5eb5b4SPaolo Bonzini __u64 to; 1193a5eb5b4SPaolo Bonzini __u64 len; 1203a5eb5b4SPaolo Bonzini } remap; 1213a5eb5b4SPaolo Bonzini 1223a5eb5b4SPaolo Bonzini struct { 1233a5eb5b4SPaolo Bonzini __u64 start; 1243a5eb5b4SPaolo Bonzini __u64 end; 12574c98e20SCornelia Huck } remove; 1263a5eb5b4SPaolo Bonzini 1273a5eb5b4SPaolo Bonzini struct { 128c1fcf220SDr. David Alan Gilbert /* unused reserved fields */ 129c1fcf220SDr. David Alan Gilbert __u64 reserved1; 130c1fcf220SDr. David Alan Gilbert __u64 reserved2; 131c1fcf220SDr. David Alan Gilbert __u64 reserved3; 132c1fcf220SDr. David Alan Gilbert } reserved; 133c1fcf220SDr. David Alan Gilbert } arg; 134b89485a5SPaolo Bonzini } __attribute__((packed)); 135c1fcf220SDr. David Alan Gilbert 136c1fcf220SDr. David Alan Gilbert /* 137c1fcf220SDr. David Alan Gilbert * Start at 0x12 and not at 0 to be more strict against bugs. 138c1fcf220SDr. David Alan Gilbert */ 139c1fcf220SDr. David Alan Gilbert #define UFFD_EVENT_PAGEFAULT 0x12 140c1fcf220SDr. David Alan Gilbert #define UFFD_EVENT_FORK 0x13 1413a5eb5b4SPaolo Bonzini #define UFFD_EVENT_REMAP 0x14 14274c98e20SCornelia Huck #define UFFD_EVENT_REMOVE 0x15 14374c98e20SCornelia Huck #define UFFD_EVENT_UNMAP 0x16 144c1fcf220SDr. David Alan Gilbert 145c1fcf220SDr. David Alan Gilbert /* flags for UFFD_EVENT_PAGEFAULT */ 146c1fcf220SDr. David Alan Gilbert #define UFFD_PAGEFAULT_FLAG_WRITE (1<<0) /* If this was a write fault */ 147c1fcf220SDr. David Alan Gilbert #define UFFD_PAGEFAULT_FLAG_WP (1<<1) /* If reason is VM_UFFD_WP */ 148278f064eSEduardo Habkost #define UFFD_PAGEFAULT_FLAG_MINOR (1<<2) /* If reason is VM_UFFD_MINOR */ 149c1fcf220SDr. David Alan Gilbert 150c1fcf220SDr. David Alan Gilbert struct uffdio_api { 151c1fcf220SDr. David Alan Gilbert /* userland asks for an API number and the features to enable */ 152c1fcf220SDr. David Alan Gilbert __u64 api; 153c1fcf220SDr. David Alan Gilbert /* 154c1fcf220SDr. David Alan Gilbert * Kernel answers below with the all available features for 155c1fcf220SDr. David Alan Gilbert * the API, this notifies userland of which events and/or 156c1fcf220SDr. David Alan Gilbert * which flags for each event are enabled in the current 157c1fcf220SDr. David Alan Gilbert * kernel. 158c1fcf220SDr. David Alan Gilbert * 159c1fcf220SDr. David Alan Gilbert * Note: UFFD_EVENT_PAGEFAULT and UFFD_PAGEFAULT_FLAG_WRITE 160c1fcf220SDr. David Alan Gilbert * are to be considered implicitly always enabled in all kernels as 161c1fcf220SDr. David Alan Gilbert * long as the uffdio_api.api requested matches UFFD_API. 1623a5eb5b4SPaolo Bonzini * 1633a5eb5b4SPaolo Bonzini * UFFD_FEATURE_MISSING_HUGETLBFS means an UFFDIO_REGISTER 1643a5eb5b4SPaolo Bonzini * with UFFDIO_REGISTER_MODE_MISSING mode will succeed on 1653a5eb5b4SPaolo Bonzini * hugetlbfs virtual memory ranges. Adding or not adding 1663a5eb5b4SPaolo Bonzini * UFFD_FEATURE_MISSING_HUGETLBFS to uffdio_api.features has 1673a5eb5b4SPaolo Bonzini * no real functional effect after UFFDIO_API returns, but 1683a5eb5b4SPaolo Bonzini * it's only useful for an initial feature set probe at 1693a5eb5b4SPaolo Bonzini * UFFDIO_API time. There are two ways to use it: 1703a5eb5b4SPaolo Bonzini * 1713a5eb5b4SPaolo Bonzini * 1) by adding UFFD_FEATURE_MISSING_HUGETLBFS to the 1723a5eb5b4SPaolo Bonzini * uffdio_api.features before calling UFFDIO_API, an error 1733a5eb5b4SPaolo Bonzini * will be returned by UFFDIO_API on a kernel without 1743a5eb5b4SPaolo Bonzini * hugetlbfs missing support 1753a5eb5b4SPaolo Bonzini * 1763a5eb5b4SPaolo Bonzini * 2) the UFFD_FEATURE_MISSING_HUGETLBFS can not be added in 1773a5eb5b4SPaolo Bonzini * uffdio_api.features and instead it will be set by the 1783a5eb5b4SPaolo Bonzini * kernel in the uffdio_api.features if the kernel supports 1793a5eb5b4SPaolo Bonzini * it, so userland can later check if the feature flag is 1803a5eb5b4SPaolo Bonzini * present in uffdio_api.features after UFFDIO_API 1813a5eb5b4SPaolo Bonzini * succeeded. 1823a5eb5b4SPaolo Bonzini * 1833a5eb5b4SPaolo Bonzini * UFFD_FEATURE_MISSING_SHMEM works the same as 1843a5eb5b4SPaolo Bonzini * UFFD_FEATURE_MISSING_HUGETLBFS, but it applies to shmem 1853a5eb5b4SPaolo Bonzini * (i.e. tmpfs and other shmem based APIs). 186d4083f50SAlexey Perevalov * 187d4083f50SAlexey Perevalov * UFFD_FEATURE_SIGBUS feature means no page-fault 188d4083f50SAlexey Perevalov * (UFFD_EVENT_PAGEFAULT) event will be delivered, instead 189d4083f50SAlexey Perevalov * a SIGBUS signal will be sent to the faulting process. 190d4083f50SAlexey Perevalov * 191d4083f50SAlexey Perevalov * UFFD_FEATURE_THREAD_ID pid of the page faulted task_struct will 192d4083f50SAlexey Perevalov * be returned, if feature is not requested 0 will be returned. 193278f064eSEduardo Habkost * 194278f064eSEduardo Habkost * UFFD_FEATURE_MINOR_HUGETLBFS indicates that minor faults 195278f064eSEduardo Habkost * can be intercepted (via REGISTER_MODE_MINOR) for 196278f064eSEduardo Habkost * hugetlbfs-backed pages. 197327d4b7fSBharata B Rao * 198327d4b7fSBharata B Rao * UFFD_FEATURE_MINOR_SHMEM indicates the same support as 199327d4b7fSBharata B Rao * UFFD_FEATURE_MINOR_HUGETLBFS, but for shmem-backed pages instead. 200e4082063SAlex Williamson * 201e4082063SAlex Williamson * UFFD_FEATURE_EXACT_ADDRESS indicates that the exact address of page 202e4082063SAlex Williamson * faults would be provided and the offset within the page would not be 203e4082063SAlex Williamson * masked. 204d525f73fSChenyi Qiang * 205d525f73fSChenyi Qiang * UFFD_FEATURE_WP_HUGETLBFS_SHMEM indicates that userfaultfd 206d525f73fSChenyi Qiang * write-protection mode is supported on both shmem and hugetlbfs. 207*d0bf492fSCédric Le Goater * 208*d0bf492fSCédric Le Goater * UFFD_FEATURE_WP_UNPOPULATED indicates that userfaultfd 209*d0bf492fSCédric Le Goater * write-protection mode will always apply to unpopulated pages 210*d0bf492fSCédric Le Goater * (i.e. empty ptes). This will be the default behavior for shmem 211*d0bf492fSCédric Le Goater * & hugetlbfs, so this flag only affects anonymous memory behavior 212*d0bf492fSCédric Le Goater * when userfault write-protection mode is registered. 213c1fcf220SDr. David Alan Gilbert */ 214c1fcf220SDr. David Alan Gilbert #define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0) 215c1fcf220SDr. David Alan Gilbert #define UFFD_FEATURE_EVENT_FORK (1<<1) 2163a5eb5b4SPaolo Bonzini #define UFFD_FEATURE_EVENT_REMAP (1<<2) 21774c98e20SCornelia Huck #define UFFD_FEATURE_EVENT_REMOVE (1<<3) 2183a5eb5b4SPaolo Bonzini #define UFFD_FEATURE_MISSING_HUGETLBFS (1<<4) 2193a5eb5b4SPaolo Bonzini #define UFFD_FEATURE_MISSING_SHMEM (1<<5) 22074c98e20SCornelia Huck #define UFFD_FEATURE_EVENT_UNMAP (1<<6) 221d4083f50SAlexey Perevalov #define UFFD_FEATURE_SIGBUS (1<<7) 222d4083f50SAlexey Perevalov #define UFFD_FEATURE_THREAD_ID (1<<8) 223278f064eSEduardo Habkost #define UFFD_FEATURE_MINOR_HUGETLBFS (1<<9) 224327d4b7fSBharata B Rao #define UFFD_FEATURE_MINOR_SHMEM (1<<10) 225e4082063SAlex Williamson #define UFFD_FEATURE_EXACT_ADDRESS (1<<11) 226d525f73fSChenyi Qiang #define UFFD_FEATURE_WP_HUGETLBFS_SHMEM (1<<12) 227*d0bf492fSCédric Le Goater #define UFFD_FEATURE_WP_UNPOPULATED (1<<13) 228c1fcf220SDr. David Alan Gilbert __u64 features; 229c1fcf220SDr. David Alan Gilbert 230c1fcf220SDr. David Alan Gilbert __u64 ioctls; 231c1fcf220SDr. David Alan Gilbert }; 232c1fcf220SDr. David Alan Gilbert 233c1fcf220SDr. David Alan Gilbert struct uffdio_range { 234c1fcf220SDr. David Alan Gilbert __u64 start; 235c1fcf220SDr. David Alan Gilbert __u64 len; 236c1fcf220SDr. David Alan Gilbert }; 237c1fcf220SDr. David Alan Gilbert 238c1fcf220SDr. David Alan Gilbert struct uffdio_register { 239c1fcf220SDr. David Alan Gilbert struct uffdio_range range; 240c1fcf220SDr. David Alan Gilbert #define UFFDIO_REGISTER_MODE_MISSING ((__u64)1<<0) 241c1fcf220SDr. David Alan Gilbert #define UFFDIO_REGISTER_MODE_WP ((__u64)1<<1) 242278f064eSEduardo Habkost #define UFFDIO_REGISTER_MODE_MINOR ((__u64)1<<2) 243c1fcf220SDr. David Alan Gilbert __u64 mode; 244c1fcf220SDr. David Alan Gilbert 245c1fcf220SDr. David Alan Gilbert /* 246c1fcf220SDr. David Alan Gilbert * kernel answers which ioctl commands are available for the 247c1fcf220SDr. David Alan Gilbert * range, keep at the end as the last 8 bytes aren't read. 248c1fcf220SDr. David Alan Gilbert */ 249c1fcf220SDr. David Alan Gilbert __u64 ioctls; 250c1fcf220SDr. David Alan Gilbert }; 251c1fcf220SDr. David Alan Gilbert 252c1fcf220SDr. David Alan Gilbert struct uffdio_copy { 253c1fcf220SDr. David Alan Gilbert __u64 dst; 254c1fcf220SDr. David Alan Gilbert __u64 src; 255c1fcf220SDr. David Alan Gilbert __u64 len; 256c1fcf220SDr. David Alan Gilbert #define UFFDIO_COPY_MODE_DONTWAKE ((__u64)1<<0) 257dc6f8d45SCornelia Huck /* 258dc6f8d45SCornelia Huck * UFFDIO_COPY_MODE_WP will map the page write protected on 259dc6f8d45SCornelia Huck * the fly. UFFDIO_COPY_MODE_WP is available only if the 260dc6f8d45SCornelia Huck * write protected ioctl is implemented for the range 261dc6f8d45SCornelia Huck * according to the uffdio_register.ioctls. 262dc6f8d45SCornelia Huck */ 263dc6f8d45SCornelia Huck #define UFFDIO_COPY_MODE_WP ((__u64)1<<1) 264c1fcf220SDr. David Alan Gilbert __u64 mode; 265c1fcf220SDr. David Alan Gilbert 266c1fcf220SDr. David Alan Gilbert /* 267c1fcf220SDr. David Alan Gilbert * "copy" is written by the ioctl and must be at the end: the 268c1fcf220SDr. David Alan Gilbert * copy_from_user will not read the last 8 bytes. 269c1fcf220SDr. David Alan Gilbert */ 270c1fcf220SDr. David Alan Gilbert __s64 copy; 271c1fcf220SDr. David Alan Gilbert }; 272c1fcf220SDr. David Alan Gilbert 273c1fcf220SDr. David Alan Gilbert struct uffdio_zeropage { 274c1fcf220SDr. David Alan Gilbert struct uffdio_range range; 275c1fcf220SDr. David Alan Gilbert #define UFFDIO_ZEROPAGE_MODE_DONTWAKE ((__u64)1<<0) 276c1fcf220SDr. David Alan Gilbert __u64 mode; 277c1fcf220SDr. David Alan Gilbert 278c1fcf220SDr. David Alan Gilbert /* 279c1fcf220SDr. David Alan Gilbert * "zeropage" is written by the ioctl and must be at the end: 280c1fcf220SDr. David Alan Gilbert * the copy_from_user will not read the last 8 bytes. 281c1fcf220SDr. David Alan Gilbert */ 282c1fcf220SDr. David Alan Gilbert __s64 zeropage; 283c1fcf220SDr. David Alan Gilbert }; 284c1fcf220SDr. David Alan Gilbert 285dc6f8d45SCornelia Huck struct uffdio_writeprotect { 286dc6f8d45SCornelia Huck struct uffdio_range range; 287dc6f8d45SCornelia Huck /* 288dc6f8d45SCornelia Huck * UFFDIO_WRITEPROTECT_MODE_WP: set the flag to write protect a range, 289dc6f8d45SCornelia Huck * unset the flag to undo protection of a range which was previously 290dc6f8d45SCornelia Huck * write protected. 291dc6f8d45SCornelia Huck * 292dc6f8d45SCornelia Huck * UFFDIO_WRITEPROTECT_MODE_DONTWAKE: set the flag to avoid waking up 293dc6f8d45SCornelia Huck * any wait thread after the operation succeeds. 294dc6f8d45SCornelia Huck * 295dc6f8d45SCornelia Huck * NOTE: Write protecting a region (WP=1) is unrelated to page faults, 296dc6f8d45SCornelia Huck * therefore DONTWAKE flag is meaningless with WP=1. Removing write 297dc6f8d45SCornelia Huck * protection (WP=0) in response to a page fault wakes the faulting 298dc6f8d45SCornelia Huck * task unless DONTWAKE is set. 299dc6f8d45SCornelia Huck */ 300dc6f8d45SCornelia Huck #define UFFDIO_WRITEPROTECT_MODE_WP ((__u64)1<<0) 301dc6f8d45SCornelia Huck #define UFFDIO_WRITEPROTECT_MODE_DONTWAKE ((__u64)1<<1) 302dc6f8d45SCornelia Huck __u64 mode; 303dc6f8d45SCornelia Huck }; 304dc6f8d45SCornelia Huck 305278f064eSEduardo Habkost struct uffdio_continue { 306278f064eSEduardo Habkost struct uffdio_range range; 307278f064eSEduardo Habkost #define UFFDIO_CONTINUE_MODE_DONTWAKE ((__u64)1<<0) 308*d0bf492fSCédric Le Goater /* 309*d0bf492fSCédric Le Goater * UFFDIO_CONTINUE_MODE_WP will map the page write protected on 310*d0bf492fSCédric Le Goater * the fly. UFFDIO_CONTINUE_MODE_WP is available only if the 311*d0bf492fSCédric Le Goater * write protected ioctl is implemented for the range 312*d0bf492fSCédric Le Goater * according to the uffdio_register.ioctls. 313*d0bf492fSCédric Le Goater */ 314*d0bf492fSCédric Le Goater #define UFFDIO_CONTINUE_MODE_WP ((__u64)1<<1) 315278f064eSEduardo Habkost __u64 mode; 316278f064eSEduardo Habkost 317278f064eSEduardo Habkost /* 318278f064eSEduardo Habkost * Fields below here are written by the ioctl and must be at the end: 319278f064eSEduardo Habkost * the copy_from_user will not read past here. 320278f064eSEduardo Habkost */ 321278f064eSEduardo Habkost __s64 mapped; 322278f064eSEduardo Habkost }; 323278f064eSEduardo Habkost 324b3c818a4SEric Farman /* 325b3c818a4SEric Farman * Flags for the userfaultfd(2) system call itself. 326b3c818a4SEric Farman */ 327b3c818a4SEric Farman 328b3c818a4SEric Farman /* 329b3c818a4SEric Farman * Create a userfaultfd that can handle page faults only in user mode. 330b3c818a4SEric Farman */ 331b3c818a4SEric Farman #define UFFD_USER_MODE_ONLY 1 332b3c818a4SEric Farman 333c1fcf220SDr. David Alan Gilbert #endif /* _LINUX_USERFAULTFD_H */ 334