1 /*
2  * This file is auto-generated. Modifications will be lost.
3  *
4  * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5  * for more information.
6  */
7 #ifndef _LINUX_USERFAULTFD_H
8 #define _LINUX_USERFAULTFD_H
9 #include <linux/types.h>
10 #define USERFAULTFD_IOC 0xAA
11 #define USERFAULTFD_IOC_NEW _IO(USERFAULTFD_IOC, 0x00)
12 #define UFFD_API ((__u64) 0xAA)
13 #define UFFD_API_REGISTER_MODES (UFFDIO_REGISTER_MODE_MISSING | UFFDIO_REGISTER_MODE_WP | UFFDIO_REGISTER_MODE_MINOR)
14 #define UFFD_API_FEATURES (UFFD_FEATURE_PAGEFAULT_FLAG_WP | 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 | UFFD_FEATURE_MINOR_HUGETLBFS | UFFD_FEATURE_MINOR_SHMEM | UFFD_FEATURE_EXACT_ADDRESS | UFFD_FEATURE_WP_HUGETLBFS_SHMEM | UFFD_FEATURE_WP_UNPOPULATED | UFFD_FEATURE_POISON | UFFD_FEATURE_WP_ASYNC | UFFD_FEATURE_MOVE)
15 #define UFFD_API_IOCTLS ((__u64) 1 << _UFFDIO_REGISTER | (__u64) 1 << _UFFDIO_UNREGISTER | (__u64) 1 << _UFFDIO_API)
16 #define UFFD_API_RANGE_IOCTLS ((__u64) 1 << _UFFDIO_WAKE | (__u64) 1 << _UFFDIO_COPY | (__u64) 1 << _UFFDIO_ZEROPAGE | (__u64) 1 << _UFFDIO_MOVE | (__u64) 1 << _UFFDIO_WRITEPROTECT | (__u64) 1 << _UFFDIO_CONTINUE | (__u64) 1 << _UFFDIO_POISON)
17 #define UFFD_API_RANGE_IOCTLS_BASIC ((__u64) 1 << _UFFDIO_WAKE | (__u64) 1 << _UFFDIO_COPY | (__u64) 1 << _UFFDIO_WRITEPROTECT | (__u64) 1 << _UFFDIO_CONTINUE | (__u64) 1 << _UFFDIO_POISON)
18 #define _UFFDIO_REGISTER (0x00)
19 #define _UFFDIO_UNREGISTER (0x01)
20 #define _UFFDIO_WAKE (0x02)
21 #define _UFFDIO_COPY (0x03)
22 #define _UFFDIO_ZEROPAGE (0x04)
23 #define _UFFDIO_MOVE (0x05)
24 #define _UFFDIO_WRITEPROTECT (0x06)
25 #define _UFFDIO_CONTINUE (0x07)
26 #define _UFFDIO_POISON (0x08)
27 #define _UFFDIO_API (0x3F)
28 #define UFFDIO 0xAA
29 #define UFFDIO_API _IOWR(UFFDIO, _UFFDIO_API, struct uffdio_api)
30 #define UFFDIO_REGISTER _IOWR(UFFDIO, _UFFDIO_REGISTER, struct uffdio_register)
31 #define UFFDIO_UNREGISTER _IOR(UFFDIO, _UFFDIO_UNREGISTER, struct uffdio_range)
32 #define UFFDIO_WAKE _IOR(UFFDIO, _UFFDIO_WAKE, struct uffdio_range)
33 #define UFFDIO_COPY _IOWR(UFFDIO, _UFFDIO_COPY, struct uffdio_copy)
34 #define UFFDIO_ZEROPAGE _IOWR(UFFDIO, _UFFDIO_ZEROPAGE, struct uffdio_zeropage)
35 #define UFFDIO_MOVE _IOWR(UFFDIO, _UFFDIO_MOVE, struct uffdio_move)
36 #define UFFDIO_WRITEPROTECT _IOWR(UFFDIO, _UFFDIO_WRITEPROTECT, struct uffdio_writeprotect)
37 #define UFFDIO_CONTINUE _IOWR(UFFDIO, _UFFDIO_CONTINUE, struct uffdio_continue)
38 #define UFFDIO_POISON _IOWR(UFFDIO, _UFFDIO_POISON, struct uffdio_poison)
39 struct uffd_msg {
40   __u8 event;
41   __u8 reserved1;
42   __u16 reserved2;
43   __u32 reserved3;
44   union {
45     struct {
46       __u64 flags;
47       __u64 address;
48       union {
49         __u32 ptid;
50       } feat;
51     } pagefault;
52     struct {
53       __u32 ufd;
54     } fork;
55     struct {
56       __u64 from;
57       __u64 to;
58       __u64 len;
59     } remap;
60     struct {
61       __u64 start;
62       __u64 end;
63     } remove;
64     struct {
65       __u64 reserved1;
66       __u64 reserved2;
67       __u64 reserved3;
68     } reserved;
69   } arg;
70 } __attribute__((__packed__));
71 #define UFFD_EVENT_PAGEFAULT 0x12
72 #define UFFD_EVENT_FORK 0x13
73 #define UFFD_EVENT_REMAP 0x14
74 #define UFFD_EVENT_REMOVE 0x15
75 #define UFFD_EVENT_UNMAP 0x16
76 #define UFFD_PAGEFAULT_FLAG_WRITE (1 << 0)
77 #define UFFD_PAGEFAULT_FLAG_WP (1 << 1)
78 #define UFFD_PAGEFAULT_FLAG_MINOR (1 << 2)
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 #define UFFD_FEATURE_MINOR_HUGETLBFS (1 << 9)
91 #define UFFD_FEATURE_MINOR_SHMEM (1 << 10)
92 #define UFFD_FEATURE_EXACT_ADDRESS (1 << 11)
93 #define UFFD_FEATURE_WP_HUGETLBFS_SHMEM (1 << 12)
94 #define UFFD_FEATURE_WP_UNPOPULATED (1 << 13)
95 #define UFFD_FEATURE_POISON (1 << 14)
96 #define UFFD_FEATURE_WP_ASYNC (1 << 15)
97 #define UFFD_FEATURE_MOVE (1 << 16)
98   __u64 features;
99   __u64 ioctls;
100 };
101 struct uffdio_range {
102   __u64 start;
103   __u64 len;
104 };
105 struct uffdio_register {
106   struct uffdio_range range;
107 #define UFFDIO_REGISTER_MODE_MISSING ((__u64) 1 << 0)
108 #define UFFDIO_REGISTER_MODE_WP ((__u64) 1 << 1)
109 #define UFFDIO_REGISTER_MODE_MINOR ((__u64) 1 << 2)
110   __u64 mode;
111   __u64 ioctls;
112 };
113 struct uffdio_copy {
114   __u64 dst;
115   __u64 src;
116   __u64 len;
117 #define UFFDIO_COPY_MODE_DONTWAKE ((__u64) 1 << 0)
118 #define UFFDIO_COPY_MODE_WP ((__u64) 1 << 1)
119   __u64 mode;
120   __s64 copy;
121 };
122 struct uffdio_zeropage {
123   struct uffdio_range range;
124 #define UFFDIO_ZEROPAGE_MODE_DONTWAKE ((__u64) 1 << 0)
125   __u64 mode;
126   __s64 zeropage;
127 };
128 struct uffdio_writeprotect {
129   struct uffdio_range range;
130 #define UFFDIO_WRITEPROTECT_MODE_WP ((__u64) 1 << 0)
131 #define UFFDIO_WRITEPROTECT_MODE_DONTWAKE ((__u64) 1 << 1)
132   __u64 mode;
133 };
134 struct uffdio_continue {
135   struct uffdio_range range;
136 #define UFFDIO_CONTINUE_MODE_DONTWAKE ((__u64) 1 << 0)
137 #define UFFDIO_CONTINUE_MODE_WP ((__u64) 1 << 1)
138   __u64 mode;
139   __s64 mapped;
140 };
141 struct uffdio_poison {
142   struct uffdio_range range;
143 #define UFFDIO_POISON_MODE_DONTWAKE ((__u64) 1 << 0)
144   __u64 mode;
145   __s64 updated;
146 };
147 struct uffdio_move {
148   __u64 dst;
149   __u64 src;
150   __u64 len;
151 #define UFFDIO_MOVE_MODE_DONTWAKE ((__u64) 1 << 0)
152 #define UFFDIO_MOVE_MODE_ALLOW_SRC_HOLES ((__u64) 1 << 1)
153   __u64 mode;
154   __s64 move;
155 };
156 #define UFFD_USER_MODE_ONLY 1
157 #endif
158