@@ -1935,10 +1935,15 @@ static int userfaultfd_api(struct userfaultfd_ctx *ctx,
goto err_out;
/* report all available features and ioctls to userland */
uffdio_api.features = UFFD_API_FEATURES;
+
#ifndef CONFIG_HAVE_ARCH_USERFAULTFD_MINOR
uffdio_api.features &=
~(UFFD_FEATURE_MINOR_HUGETLBFS | UFFD_FEATURE_MINOR_SHMEM);
-#endif
+#ifndef CONFIG_HUGETLB_HIGH_GRANULARITY_MAPPING
+ uffdio_api.features &= ~UFFD_FEATURE_MINOR_HUGETLBFS_HGM;
+#endif /* CONFIG_HUGETLB_HIGH_GRANULARITY_MAPPING */
+#endif /* CONFIG_HAVE_ARCH_USERFAULTFD_MINOR */
+
#ifndef CONFIG_HAVE_ARCH_USERFAULTFD_WP
uffdio_api.features &= ~UFFD_FEATURE_PAGEFAULT_FLAG_WP;
#endif
@@ -32,6 +32,7 @@
UFFD_FEATURE_SIGBUS | \
UFFD_FEATURE_THREAD_ID | \
UFFD_FEATURE_MINOR_HUGETLBFS | \
+ UFFD_FEATURE_MINOR_HUGETLBFS_HGM | \
UFFD_FEATURE_MINOR_SHMEM | \
UFFD_FEATURE_EXACT_ADDRESS | \
UFFD_FEATURE_WP_HUGETLBFS_SHMEM)
@@ -213,6 +214,7 @@ struct uffdio_api {
#define UFFD_FEATURE_MINOR_SHMEM (1<<10)
#define UFFD_FEATURE_EXACT_ADDRESS (1<<11)
#define UFFD_FEATURE_WP_HUGETLBFS_SHMEM (1<<12)
+#define UFFD_FEATURE_MINOR_HUGETLBFS_HGM (1<<13)
__u64 features;
__u64 ioctls;
This is so that userspace is aware that their kernel was compiled with HugeTLB high-granularity mapping and that UFFDIO_CONTINUE down to PAGE_SIZE-aligned chunks are valid. Signed-off-by: James Houghton <jthoughton@google.com> --- fs/userfaultfd.c | 7 ++++++- include/uapi/linux/userfaultfd.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-)