1
2
3
4
5
6
7
8
9#ifndef _LINUX_USERFAULTFD_H
10#define _LINUX_USERFAULTFD_H
11
12#include <linux/types.h>
13
14#define UFFD_API ((__u64)0xAA)
15
16
17
18
19
20#define UFFD_API_FEATURES (0)
21#define UFFD_API_IOCTLS \
22 ((__u64)1 << _UFFDIO_REGISTER | \
23 (__u64)1 << _UFFDIO_UNREGISTER | \
24 (__u64)1 << _UFFDIO_API)
25#define UFFD_API_RANGE_IOCTLS \
26 ((__u64)1 << _UFFDIO_WAKE | \
27 (__u64)1 << _UFFDIO_COPY | \
28 (__u64)1 << _UFFDIO_ZEROPAGE)
29
30
31
32
33
34
35
36
37
38#define _UFFDIO_REGISTER (0x00)
39#define _UFFDIO_UNREGISTER (0x01)
40#define _UFFDIO_WAKE (0x02)
41#define _UFFDIO_COPY (0x03)
42#define _UFFDIO_ZEROPAGE (0x04)
43#define _UFFDIO_API (0x3F)
44
45
46#define UFFDIO 0xAA
47#define UFFDIO_API _IOWR(UFFDIO, _UFFDIO_API, \
48 struct uffdio_api)
49#define UFFDIO_REGISTER _IOWR(UFFDIO, _UFFDIO_REGISTER, \
50 struct uffdio_register)
51#define UFFDIO_UNREGISTER _IOR(UFFDIO, _UFFDIO_UNREGISTER, \
52 struct uffdio_range)
53#define UFFDIO_WAKE _IOR(UFFDIO, _UFFDIO_WAKE, \
54 struct uffdio_range)
55#define UFFDIO_COPY _IOWR(UFFDIO, _UFFDIO_COPY, \
56 struct uffdio_copy)
57#define UFFDIO_ZEROPAGE _IOWR(UFFDIO, _UFFDIO_ZEROPAGE, \
58 struct uffdio_zeropage)
59
60
61struct uffd_msg {
62 __u8 event;
63
64 __u8 reserved1;
65 __u16 reserved2;
66 __u32 reserved3;
67
68 union {
69 struct {
70 __u64 flags;
71 __u64 address;
72 } pagefault;
73
74 struct {
75
76 __u64 reserved1;
77 __u64 reserved2;
78 __u64 reserved3;
79 } reserved;
80 } arg;
81} __attribute__((packed));
82
83
84
85
86#define UFFD_EVENT_PAGEFAULT 0x12
87#if 0
88#define UFFD_EVENT_FORK 0x13
89#endif
90
91
92#define UFFD_PAGEFAULT_FLAG_WRITE (1<<0)
93#define UFFD_PAGEFAULT_FLAG_WP (1<<1)
94
95struct uffdio_api {
96
97 __u64 api;
98
99
100
101
102
103
104
105
106
107
108#if 0
109#define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0)
110#define UFFD_FEATURE_EVENT_FORK (1<<1)
111#endif
112 __u64 features;
113
114 __u64 ioctls;
115};
116
117struct uffdio_range {
118 __u64 start;
119 __u64 len;
120};
121
122struct uffdio_register {
123 struct uffdio_range range;
124#define UFFDIO_REGISTER_MODE_MISSING ((__u64)1<<0)
125#define UFFDIO_REGISTER_MODE_WP ((__u64)1<<1)
126 __u64 mode;
127
128
129
130
131
132 __u64 ioctls;
133};
134
135struct uffdio_copy {
136 __u64 dst;
137 __u64 src;
138 __u64 len;
139
140
141
142
143
144
145#define UFFDIO_COPY_MODE_DONTWAKE ((__u64)1<<0)
146 __u64 mode;
147
148
149
150
151
152 __s64 copy;
153};
154
155struct uffdio_zeropage {
156 struct uffdio_range range;
157#define UFFDIO_ZEROPAGE_MODE_DONTWAKE ((__u64)1<<0)
158 __u64 mode;
159
160
161
162
163
164 __s64 zeropage;
165};
166
167#endif
168