aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux
diff options
context:
space:
mode:
authorAndrea Arcangeli <aarcange@redhat.com>2015-09-04 18:46:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-09-04 19:54:41 -0400
commit1038628d80e96e3a086189172d9be8eb85ecfabf (patch)
tree50d970e531405f4a472ffc52070f749591a4dfa2 /include/uapi/linux
parent51360155eccb907ff8635bd10fc7de876408c2e0 (diff)
userfaultfd: uAPI
Defines the uAPI of the userfaultfd, notably the ioctl numbers and protocol. Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Acked-by: Pavel Emelyanov <xemul@parallels.com> Cc: Sanidhya Kashyap <sanidhya.gatech@gmail.com> Cc: zhang.zhanghailiang@huawei.com Cc: "Kirill A. Shutemov" <kirill@shutemov.name> Cc: Andres Lagar-Cavilla <andreslc@google.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Rik van Riel <riel@redhat.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Hugh Dickins <hughd@google.com> Cc: Peter Feiner <pfeiner@google.com> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: "Huangpeng (Peter)" <peter.huangpeng@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/uapi/linux')
-rw-r--r--include/uapi/linux/Kbuild1
-rw-r--r--include/uapi/linux/userfaultfd.h83
2 files changed, 84 insertions, 0 deletions
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index aafb9937b162..70ff1d9abf0d 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -456,3 +456,4 @@ header-y += xfrm.h
456header-y += xilinx-v4l2-controls.h 456header-y += xilinx-v4l2-controls.h
457header-y += zorro.h 457header-y += zorro.h
458header-y += zorro_ids.h 458header-y += zorro_ids.h
459header-y += userfaultfd.h
diff --git a/include/uapi/linux/userfaultfd.h b/include/uapi/linux/userfaultfd.h
new file mode 100644
index 000000000000..09c2e2a8c9d6
--- /dev/null
+++ b/include/uapi/linux/userfaultfd.h
@@ -0,0 +1,83 @@
1/*
2 * include/linux/userfaultfd.h
3 *
4 * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org>
5 * Copyright (C) 2015 Red Hat, Inc.
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/* FIXME: add "|UFFD_BIT_WP" to UFFD_API_BITS after implementing it */
16#define UFFD_API_BITS (UFFD_BIT_WRITE)
17#define UFFD_API_IOCTLS \
18 ((__u64)1 << _UFFDIO_REGISTER | \
19 (__u64)1 << _UFFDIO_UNREGISTER | \
20 (__u64)1 << _UFFDIO_API)
21#define UFFD_API_RANGE_IOCTLS \
22 ((__u64)1 << _UFFDIO_WAKE)
23
24/*
25 * Valid ioctl command number range with this API is from 0x00 to
26 * 0x3F. UFFDIO_API is the fixed number, everything else can be
27 * changed by implementing a different UFFD_API. If sticking to the
28 * same UFFD_API more ioctl can be added and userland will be aware of
29 * which ioctl the running kernel implements through the ioctl command
30 * bitmask written by the UFFDIO_API.
31 */
32#define _UFFDIO_REGISTER (0x00)
33#define _UFFDIO_UNREGISTER (0x01)
34#define _UFFDIO_WAKE (0x02)
35#define _UFFDIO_API (0x3F)
36
37/* userfaultfd ioctl ids */
38#define UFFDIO 0xAA
39#define UFFDIO_API _IOWR(UFFDIO, _UFFDIO_API, \
40 struct uffdio_api)
41#define UFFDIO_REGISTER _IOWR(UFFDIO, _UFFDIO_REGISTER, \
42 struct uffdio_register)
43#define UFFDIO_UNREGISTER _IOR(UFFDIO, _UFFDIO_UNREGISTER, \
44 struct uffdio_range)
45#define UFFDIO_WAKE _IOR(UFFDIO, _UFFDIO_WAKE, \
46 struct uffdio_range)
47
48/*
49 * Valid bits below PAGE_SHIFT in the userfault address read through
50 * the read() syscall.
51 */
52#define UFFD_BIT_WRITE (1<<0) /* this was a write fault, MISSING or WP */
53#define UFFD_BIT_WP (1<<1) /* handle_userfault() reason VM_UFFD_WP */
54#define UFFD_BITS 2 /* two above bits used for UFFD_BIT_* mask */
55
56struct uffdio_api {
57 /* userland asks for an API number */
58 __u64 api;
59
60 /* kernel answers below with the available features for the API */
61 __u64 bits;
62 __u64 ioctls;
63};
64
65struct uffdio_range {
66 __u64 start;
67 __u64 len;
68};
69
70struct uffdio_register {
71 struct uffdio_range range;
72#define UFFDIO_REGISTER_MODE_MISSING ((__u64)1<<0)
73#define UFFDIO_REGISTER_MODE_WP ((__u64)1<<1)
74 __u64 mode;
75
76 /*
77 * kernel answers which ioctl commands are available for the
78 * range, keep at the end as the last 8 bytes aren't read.
79 */
80 __u64 ioctls;
81};
82
83#endif /* _LINUX_USERFAULTFD_H */