]> Git Repo - qemu.git/blobdiff - linux-headers/linux/userfaultfd.h
Merge remote-tracking branch 'remotes/thuth-gitlab/tags/pull-request-2021-06-02'...
[qemu.git] / linux-headers / linux / userfaultfd.h
index ce78878d127e62968cd3139e5fd8431d8618bfbf..1ba9a9feeb833e16bcffefa044dee6927991e8ad 100644 (file)
@@ -19,7 +19,8 @@
  * means the userland is reading).
  */
 #define UFFD_API ((__u64)0xAA)
-#define UFFD_API_FEATURES (UFFD_FEATURE_EVENT_FORK |           \
+#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 |           \
@@ -34,7 +35,8 @@
 #define UFFD_API_RANGE_IOCTLS                  \
        ((__u64)1 << _UFFDIO_WAKE |             \
         (__u64)1 << _UFFDIO_COPY |             \
-        (__u64)1 << _UFFDIO_ZEROPAGE)
+        (__u64)1 << _UFFDIO_ZEROPAGE |         \
+        (__u64)1 << _UFFDIO_WRITEPROTECT)
 #define UFFD_API_RANGE_IOCTLS_BASIC            \
        ((__u64)1 << _UFFDIO_WAKE |             \
         (__u64)1 << _UFFDIO_COPY)
@@ -52,6 +54,7 @@
 #define _UFFDIO_WAKE                   (0x02)
 #define _UFFDIO_COPY                   (0x03)
 #define _UFFDIO_ZEROPAGE               (0x04)
+#define _UFFDIO_WRITEPROTECT           (0x06)
 #define _UFFDIO_API                    (0x3F)
 
 /* userfaultfd ioctl ids */
@@ -68,6 +71,8 @@
                                      struct uffdio_copy)
 #define UFFDIO_ZEROPAGE                _IOWR(UFFDIO, _UFFDIO_ZEROPAGE, \
                                      struct uffdio_zeropage)
+#define UFFDIO_WRITEPROTECT    _IOWR(UFFDIO, _UFFDIO_WRITEPROTECT, \
+                                     struct uffdio_writeprotect)
 
 /* read() structure */
 struct uffd_msg {
@@ -203,13 +208,14 @@ struct uffdio_copy {
        __u64 dst;
        __u64 src;
        __u64 len;
+#define UFFDIO_COPY_MODE_DONTWAKE              ((__u64)1<<0)
        /*
-        * 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.
+        * UFFDIO_COPY_MODE_WP will map the page write protected on
+        * the fly.  UFFDIO_COPY_MODE_WP is available only if the
+        * write protected ioctl is implemented for the range
+        * according to the uffdio_register.ioctls.
         */
-#define UFFDIO_COPY_MODE_DONTWAKE              ((__u64)1<<0)
+#define UFFDIO_COPY_MODE_WP                    ((__u64)1<<1)
        __u64 mode;
 
        /*
@@ -231,4 +237,33 @@ struct uffdio_zeropage {
        __s64 zeropage;
 };
 
+struct uffdio_writeprotect {
+       struct uffdio_range range;
+/*
+ * UFFDIO_WRITEPROTECT_MODE_WP: set the flag to write protect a range,
+ * unset the flag to undo protection of a range which was previously
+ * write protected.
+ *
+ * UFFDIO_WRITEPROTECT_MODE_DONTWAKE: set the flag to avoid waking up
+ * any wait thread after the operation succeeds.
+ *
+ * NOTE: Write protecting a region (WP=1) is unrelated to page faults,
+ * therefore DONTWAKE flag is meaningless with WP=1.  Removing write
+ * protection (WP=0) in response to a page fault wakes the faulting
+ * task unless DONTWAKE is set.
+ */
+#define UFFDIO_WRITEPROTECT_MODE_WP            ((__u64)1<<0)
+#define UFFDIO_WRITEPROTECT_MODE_DONTWAKE      ((__u64)1<<1)
+       __u64 mode;
+};
+
+/*
+ * Flags for the userfaultfd(2) system call itself.
+ */
+
+/*
+ * Create a userfaultfd that can handle page faults only in user mode.
+ */
+#define UFFD_USER_MODE_ONLY 1
+
 #endif /* _LINUX_USERFAULTFD_H */
This page took 0.03021 seconds and 4 git commands to generate.