Commit 3f602d27 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Linus Torvalds

userfaultfd: Rename uffd_api.bits into .features

This is (seems to be) the minimal thing that is required to unblock
standard uffd usage from the non-cooperative one.  Now more bits can be
added to the features field indicating e.g.  UFFD_FEATURE_FORK and others
needed for the latter use-case.
Signed-off-by: default avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: default avatarAndrea Arcangeli <aarcange@redhat.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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 86039bd3
...@@ -884,7 +884,7 @@ static int userfaultfd_api(struct userfaultfd_ctx *ctx, ...@@ -884,7 +884,7 @@ static int userfaultfd_api(struct userfaultfd_ctx *ctx,
goto out; goto out;
} }
/* careful not to leak info, we only read the first 8 bytes */ /* careful not to leak info, we only read the first 8 bytes */
uffdio_api.bits = UFFD_API_BITS; uffdio_api.features = UFFD_API_FEATURES;
uffdio_api.ioctls = UFFD_API_IOCTLS; uffdio_api.ioctls = UFFD_API_IOCTLS;
ret = -EFAULT; ret = -EFAULT;
if (copy_to_user(buf, &uffdio_api, sizeof(uffdio_api))) if (copy_to_user(buf, &uffdio_api, sizeof(uffdio_api)))
...@@ -941,7 +941,7 @@ static void userfaultfd_show_fdinfo(struct seq_file *m, struct file *f) ...@@ -941,7 +941,7 @@ static void userfaultfd_show_fdinfo(struct seq_file *m, struct file *f)
* protocols: aa:... bb:... * protocols: aa:... bb:...
*/ */
seq_printf(m, "pending:\t%lu\ntotal:\t%lu\nAPI:\t%Lx:%x:%Lx\n", seq_printf(m, "pending:\t%lu\ntotal:\t%lu\nAPI:\t%Lx:%x:%Lx\n",
pending, total, UFFD_API, UFFD_API_BITS, pending, total, UFFD_API, UFFD_API_FEATURES,
UFFD_API_IOCTLS|UFFD_API_RANGE_IOCTLS); UFFD_API_IOCTLS|UFFD_API_RANGE_IOCTLS);
} }
#endif #endif
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#include <linux/types.h> #include <linux/types.h>
#define UFFD_API ((__u64)0xAA) #define UFFD_API ((__u64)0xAA)
/* FIXME: add "|UFFD_BIT_WP" to UFFD_API_BITS after implementing it */ /* FIXME: add "|UFFD_FEATURE_WP" to UFFD_API_FEATURES after implementing it */
#define UFFD_API_BITS (UFFD_BIT_WRITE) #define UFFD_API_FEATURES (UFFD_FEATURE_WRITE_BIT)
#define UFFD_API_IOCTLS \ #define UFFD_API_IOCTLS \
((__u64)1 << _UFFDIO_REGISTER | \ ((__u64)1 << _UFFDIO_REGISTER | \
(__u64)1 << _UFFDIO_UNREGISTER | \ (__u64)1 << _UFFDIO_UNREGISTER | \
...@@ -53,12 +53,18 @@ ...@@ -53,12 +53,18 @@
#define UFFD_BIT_WP (1<<1) /* handle_userfault() reason VM_UFFD_WP */ #define UFFD_BIT_WP (1<<1) /* handle_userfault() reason VM_UFFD_WP */
#define UFFD_BITS 2 /* two above bits used for UFFD_BIT_* mask */ #define UFFD_BITS 2 /* two above bits used for UFFD_BIT_* mask */
/*
* Features reported in uffdio_api.features field
*/
#define UFFD_FEATURE_WRITE_BIT (1<<0) /* Corresponds to UFFD_BIT_WRITE */
#define UFFD_FEATURE_WP_BIT (1<<1) /* Corresponds to UFFD_BIT_WP */
struct uffdio_api { struct uffdio_api {
/* userland asks for an API number */ /* userland asks for an API number */
__u64 api; __u64 api;
/* kernel answers below with the available features for the API */ /* kernel answers below with the available features for the API */
__u64 bits; __u64 features;
__u64 ioctls; __u64 ioctls;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment