Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Andrea 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Pavel Emelyanov and committed by
Linus Torvalds
3f602d27 86039bd3

+11 -5
+2 -2
fs/userfaultfd.c
··· 884 884 goto out; 885 885 } 886 886 /* careful not to leak info, we only read the first 8 bytes */ 887 - uffdio_api.bits = UFFD_API_BITS; 887 + uffdio_api.features = UFFD_API_FEATURES; 888 888 uffdio_api.ioctls = UFFD_API_IOCTLS; 889 889 ret = -EFAULT; 890 890 if (copy_to_user(buf, &uffdio_api, sizeof(uffdio_api))) ··· 941 941 * protocols: aa:... bb:... 942 942 */ 943 943 seq_printf(m, "pending:\t%lu\ntotal:\t%lu\nAPI:\t%Lx:%x:%Lx\n", 944 - pending, total, UFFD_API, UFFD_API_BITS, 944 + pending, total, UFFD_API, UFFD_API_FEATURES, 945 945 UFFD_API_IOCTLS|UFFD_API_RANGE_IOCTLS); 946 946 } 947 947 #endif
+9 -3
include/uapi/linux/userfaultfd.h
··· 12 12 #include <linux/types.h> 13 13 14 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) 15 + /* FIXME: add "|UFFD_FEATURE_WP" to UFFD_API_FEATURES after implementing it */ 16 + #define UFFD_API_FEATURES (UFFD_FEATURE_WRITE_BIT) 17 17 #define UFFD_API_IOCTLS \ 18 18 ((__u64)1 << _UFFDIO_REGISTER | \ 19 19 (__u64)1 << _UFFDIO_UNREGISTER | \ ··· 53 53 #define UFFD_BIT_WP (1<<1) /* handle_userfault() reason VM_UFFD_WP */ 54 54 #define UFFD_BITS 2 /* two above bits used for UFFD_BIT_* mask */ 55 55 56 + /* 57 + * Features reported in uffdio_api.features field 58 + */ 59 + #define UFFD_FEATURE_WRITE_BIT (1<<0) /* Corresponds to UFFD_BIT_WRITE */ 60 + #define UFFD_FEATURE_WP_BIT (1<<1) /* Corresponds to UFFD_BIT_WP */ 61 + 56 62 struct uffdio_api { 57 63 /* userland asks for an API number */ 58 64 __u64 api; 59 65 60 66 /* kernel answers below with the available features for the API */ 61 - __u64 bits; 67 + __u64 features; 62 68 __u64 ioctls; 63 69 }; 64 70