1 /**************************************************************************** 2 **************************************************************************** 3 *** 4 *** This header was automatically generated from a Linux kernel header 5 *** of the same name, to make information necessary for userspace to 6 *** call into the kernel available to libc. It contains only constants, 7 *** structures, and macros generated from the original header, and thus, 8 *** contains no copyrightable information. 9 *** 10 *** To edit the content of this header, modify the corresponding 11 *** source file (e.g. under external/kernel-headers/original/) then 12 *** run bionic/libc/kernel/tools/update_all.py 13 *** 14 *** Any manual change here will be lost the next time this script will 15 *** be run. You've been warned! 16 *** 17 **************************************************************************** 18 ****************************************************************************/ 19 #ifndef _LINUX_USERFAULTFD_H 20 #define _LINUX_USERFAULTFD_H 21 #include <linux/types.h> 22 #define UFFD_API ((__u64) 0xAA) 23 #define UFFD_API_FEATURES (UFFD_FEATURE_EVENT_FORK | UFFD_FEATURE_EVENT_REMAP | UFFD_FEATURE_EVENT_REMOVE | UFFD_FEATURE_EVENT_UNMAP | UFFD_FEATURE_MISSING_HUGETLBFS | UFFD_FEATURE_MISSING_SHMEM | UFFD_FEATURE_SIGBUS | UFFD_FEATURE_THREAD_ID) 24 #define UFFD_API_IOCTLS ((__u64) 1 << _UFFDIO_REGISTER | (__u64) 1 << _UFFDIO_UNREGISTER | (__u64) 1 << _UFFDIO_API) 25 #define UFFD_API_RANGE_IOCTLS ((__u64) 1 << _UFFDIO_WAKE | (__u64) 1 << _UFFDIO_COPY | (__u64) 1 << _UFFDIO_ZEROPAGE) 26 #define UFFD_API_RANGE_IOCTLS_BASIC ((__u64) 1 << _UFFDIO_WAKE | (__u64) 1 << _UFFDIO_COPY) 27 #define _UFFDIO_REGISTER (0x00) 28 #define _UFFDIO_UNREGISTER (0x01) 29 #define _UFFDIO_WAKE (0x02) 30 #define _UFFDIO_COPY (0x03) 31 #define _UFFDIO_ZEROPAGE (0x04) 32 #define _UFFDIO_API (0x3F) 33 #define UFFDIO 0xAA 34 #define UFFDIO_API _IOWR(UFFDIO, _UFFDIO_API, struct uffdio_api) 35 #define UFFDIO_REGISTER _IOWR(UFFDIO, _UFFDIO_REGISTER, struct uffdio_register) 36 #define UFFDIO_UNREGISTER _IOR(UFFDIO, _UFFDIO_UNREGISTER, struct uffdio_range) 37 #define UFFDIO_WAKE _IOR(UFFDIO, _UFFDIO_WAKE, struct uffdio_range) 38 #define UFFDIO_COPY _IOWR(UFFDIO, _UFFDIO_COPY, struct uffdio_copy) 39 #define UFFDIO_ZEROPAGE _IOWR(UFFDIO, _UFFDIO_ZEROPAGE, struct uffdio_zeropage) 40 struct uffd_msg { 41 __u8 event; 42 __u8 reserved1; 43 __u16 reserved2; 44 __u32 reserved3; 45 union { 46 struct { 47 __u64 flags; 48 __u64 address; 49 union { 50 __u32 ptid; 51 } feat; 52 } pagefault; 53 struct { 54 __u32 ufd; 55 } fork; 56 struct { 57 __u64 from; 58 __u64 to; 59 __u64 len; 60 } remap; 61 struct { 62 __u64 start; 63 __u64 end; 64 } remove; 65 struct { 66 __u64 reserved1; 67 __u64 reserved2; 68 __u64 reserved3; 69 } reserved; 70 } arg; 71 } __packed; 72 #define UFFD_EVENT_PAGEFAULT 0x12 73 #define UFFD_EVENT_FORK 0x13 74 #define UFFD_EVENT_REMAP 0x14 75 #define UFFD_EVENT_REMOVE 0x15 76 #define UFFD_EVENT_UNMAP 0x16 77 #define UFFD_PAGEFAULT_FLAG_WRITE (1 << 0) 78 #define UFFD_PAGEFAULT_FLAG_WP (1 << 1) 79 struct uffdio_api { 80 __u64 api; 81 #define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1 << 0) 82 #define UFFD_FEATURE_EVENT_FORK (1 << 1) 83 #define UFFD_FEATURE_EVENT_REMAP (1 << 2) 84 #define UFFD_FEATURE_EVENT_REMOVE (1 << 3) 85 #define UFFD_FEATURE_MISSING_HUGETLBFS (1 << 4) 86 #define UFFD_FEATURE_MISSING_SHMEM (1 << 5) 87 #define UFFD_FEATURE_EVENT_UNMAP (1 << 6) 88 #define UFFD_FEATURE_SIGBUS (1 << 7) 89 #define UFFD_FEATURE_THREAD_ID (1 << 8) 90 __u64 features; 91 __u64 ioctls; 92 }; 93 struct uffdio_range { 94 __u64 start; 95 __u64 len; 96 }; 97 struct uffdio_register { 98 struct uffdio_range range; 99 #define UFFDIO_REGISTER_MODE_MISSING ((__u64) 1 << 0) 100 #define UFFDIO_REGISTER_MODE_WP ((__u64) 1 << 1) 101 __u64 mode; 102 __u64 ioctls; 103 }; 104 struct uffdio_copy { 105 __u64 dst; 106 __u64 src; 107 __u64 len; 108 #define UFFDIO_COPY_MODE_DONTWAKE ((__u64) 1 << 0) 109 __u64 mode; 110 __s64 copy; 111 }; 112 struct uffdio_zeropage { 113 struct uffdio_range range; 114 #define UFFDIO_ZEROPAGE_MODE_DONTWAKE ((__u64) 1 << 0) 115 __u64 mode; 116 __s64 zeropage; 117 }; 118 #endif 119