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_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)
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 | (__u64) 1 << _UFFDIO_WRITEPROTECT)
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_WRITEPROTECT (0x06)
33 #define _UFFDIO_API (0x3F)
34 #define UFFDIO 0xAA
35 #define UFFDIO_API _IOWR(UFFDIO, _UFFDIO_API, struct uffdio_api)
36 #define UFFDIO_REGISTER _IOWR(UFFDIO, _UFFDIO_REGISTER, struct uffdio_register)
37 #define UFFDIO_UNREGISTER _IOR(UFFDIO, _UFFDIO_UNREGISTER, struct uffdio_range)
38 #define UFFDIO_WAKE _IOR(UFFDIO, _UFFDIO_WAKE, struct uffdio_range)
39 #define UFFDIO_COPY _IOWR(UFFDIO, _UFFDIO_COPY, struct uffdio_copy)
40 #define UFFDIO_ZEROPAGE _IOWR(UFFDIO, _UFFDIO_ZEROPAGE, struct uffdio_zeropage)
41 #define UFFDIO_WRITEPROTECT _IOWR(UFFDIO, _UFFDIO_WRITEPROTECT, struct uffdio_writeprotect)
42 struct uffd_msg {
43   __u8 event;
44   __u8 reserved1;
45   __u16 reserved2;
46   __u32 reserved3;
47   union {
48     struct {
49       __u64 flags;
50       __u64 address;
51       union {
52         __u32 ptid;
53       } feat;
54     } pagefault;
55     struct {
56       __u32 ufd;
57     } fork;
58     struct {
59       __u64 from;
60       __u64 to;
61       __u64 len;
62     } remap;
63     struct {
64       __u64 start;
65       __u64 end;
66     } remove;
67     struct {
68       __u64 reserved1;
69       __u64 reserved2;
70       __u64 reserved3;
71     } reserved;
72   } arg;
73 } __packed;
74 #define UFFD_EVENT_PAGEFAULT 0x12
75 #define UFFD_EVENT_FORK 0x13
76 #define UFFD_EVENT_REMAP 0x14
77 #define UFFD_EVENT_REMOVE 0x15
78 #define UFFD_EVENT_UNMAP 0x16
79 #define UFFD_PAGEFAULT_FLAG_WRITE (1 << 0)
80 #define UFFD_PAGEFAULT_FLAG_WP (1 << 1)
81 struct uffdio_api {
82   __u64 api;
83 #define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1 << 0)
84 #define UFFD_FEATURE_EVENT_FORK (1 << 1)
85 #define UFFD_FEATURE_EVENT_REMAP (1 << 2)
86 #define UFFD_FEATURE_EVENT_REMOVE (1 << 3)
87 #define UFFD_FEATURE_MISSING_HUGETLBFS (1 << 4)
88 #define UFFD_FEATURE_MISSING_SHMEM (1 << 5)
89 #define UFFD_FEATURE_EVENT_UNMAP (1 << 6)
90 #define UFFD_FEATURE_SIGBUS (1 << 7)
91 #define UFFD_FEATURE_THREAD_ID (1 << 8)
92   __u64 features;
93   __u64 ioctls;
94 };
95 struct uffdio_range {
96   __u64 start;
97   __u64 len;
98 };
99 struct uffdio_register {
100   struct uffdio_range range;
101 #define UFFDIO_REGISTER_MODE_MISSING ((__u64) 1 << 0)
102 #define UFFDIO_REGISTER_MODE_WP ((__u64) 1 << 1)
103   __u64 mode;
104   __u64 ioctls;
105 };
106 struct uffdio_copy {
107   __u64 dst;
108   __u64 src;
109   __u64 len;
110 #define UFFDIO_COPY_MODE_DONTWAKE ((__u64) 1 << 0)
111 #define UFFDIO_COPY_MODE_WP ((__u64) 1 << 1)
112   __u64 mode;
113   __s64 copy;
114 };
115 struct uffdio_zeropage {
116   struct uffdio_range range;
117 #define UFFDIO_ZEROPAGE_MODE_DONTWAKE ((__u64) 1 << 0)
118   __u64 mode;
119   __s64 zeropage;
120 };
121 struct uffdio_writeprotect {
122   struct uffdio_range range;
123 #define UFFDIO_WRITEPROTECT_MODE_WP ((__u64) 1 << 0)
124 #define UFFDIO_WRITEPROTECT_MODE_DONTWAKE ((__u64) 1 << 1)
125   __u64 mode;
126 };
127 #endif
128