userfaultfd: UFFDIO_COPY|UFFDIO_ZEROPAGE uAPI
authorAndrea Arcangeli <aarcange@redhat.com>
Fri, 4 Sep 2015 22:47:01 +0000 (15:47 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 4 Sep 2015 23:54:41 +0000 (16:54 -0700)
This implements the uABI of UFFDIO_COPY and UFFDIO_ZEROPAGE.

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>
include/uapi/linux/userfaultfd.h

index a5f8825381ef07f07ef63d346f5d30c807428266..df0e09bb7dd5a20f068b6b2a916d6a33a3ccf5ef 100644 (file)
@@ -25,7 +25,9 @@
         (__u64)1 << _UFFDIO_UNREGISTER |       \
         (__u64)1 << _UFFDIO_API)
 #define UFFD_API_RANGE_IOCTLS                  \
-       ((__u64)1 << _UFFDIO_WAKE)
+       ((__u64)1 << _UFFDIO_WAKE |             \
+        (__u64)1 << _UFFDIO_COPY |             \
+        (__u64)1 << _UFFDIO_ZEROPAGE)
 
 /*
  * Valid ioctl command number range with this API is from 0x00 to
@@ -38,6 +40,8 @@
 #define _UFFDIO_REGISTER               (0x00)
 #define _UFFDIO_UNREGISTER             (0x01)
 #define _UFFDIO_WAKE                   (0x02)
+#define _UFFDIO_COPY                   (0x03)
+#define _UFFDIO_ZEROPAGE               (0x04)
 #define _UFFDIO_API                    (0x3F)
 
 /* userfaultfd ioctl ids */
                                     struct uffdio_range)
 #define UFFDIO_WAKE            _IOR(UFFDIO, _UFFDIO_WAKE,      \
                                     struct uffdio_range)
+#define UFFDIO_COPY            _IOWR(UFFDIO, _UFFDIO_COPY,     \
+                                     struct uffdio_copy)
+#define UFFDIO_ZEROPAGE                _IOWR(UFFDIO, _UFFDIO_ZEROPAGE, \
+                                     struct uffdio_zeropage)
 
 /* read() structure */
 struct uffd_msg {
@@ -126,4 +134,36 @@ struct uffdio_register {
        __u64 ioctls;
 };
 
+struct uffdio_copy {
+       __u64 dst;
+       __u64 src;
+       __u64 len;
+       /*
+        * There will be a wrprotection flag later that allows to map
+        * pages wrprotected on the fly. And such a flag will be
+        * available if the wrprotection ioctl are implemented for the
+        * range according to the uffdio_register.ioctls.
+        */
+#define UFFDIO_COPY_MODE_DONTWAKE              ((__u64)1<<0)
+       __u64 mode;
+
+       /*
+        * "copy" is written by the ioctl and must be at the end: the
+        * copy_from_user will not read the last 8 bytes.
+        */
+       __s64 copy;
+};
+
+struct uffdio_zeropage {
+       struct uffdio_range range;
+#define UFFDIO_ZEROPAGE_MODE_DONTWAKE          ((__u64)1<<0)
+       __u64 mode;
+
+       /*
+        * "zeropage" is written by the ioctl and must be at the end:
+        * the copy_from_user will not read the last 8 bytes.
+        */
+       __s64 zeropage;
+};
+
 #endif /* _LINUX_USERFAULTFD_H */
This page took 0.026864 seconds and 5 git commands to generate.