]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/userfaultfd: Align poison function definitions for uffd_ops
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Fri, 24 Oct 2025 02:59:32 +0000 (22:59 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 30 Oct 2025 16:38:59 +0000 (12:38 -0400)
hugetlb is the most special of memory types, requiring more options for
callers than the rest.  Aligning the function definitions allows for a
uffd ops pointer to be used for memory types.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
include/linux/userfaultfd_k.h
mm/hugetlb.c
mm/shmem.c
mm/userfaultfd.c

index d3b9d8adf32d4faca85dc29d3f4ba5f6f35df3b0..fee5a904fbd03c168e1e29842e6c8fa410896fde 100644 (file)
@@ -98,6 +98,9 @@ ssize_t uffd_failed_do_unlock(struct userfaultfd_ctx *ctx,
                unsigned long src_addr);
 
 struct vm_uffd_ops {
+       int (*poison)(struct vm_area_struct *dst_vma,
+               unsigned long dst_addr, unsigned long increment);
+
        /* Required features below */
        ssize_t (*is_dst_valid)(struct vm_area_struct *dst_vma,
                                unsigned long dst_start, unsigned long len);
@@ -227,6 +230,8 @@ static inline unsigned long mfill_size(struct vm_area_struct *vma)
 {
        return PAGE_SIZE;
 }
+int mfill_atomic_pte_poison(struct vm_area_struct *dst_vma,
+               unsigned long dst_addr, unsigned long increment);
 
 static inline bool vma_can_userfault(struct vm_area_struct *vma,
                                     vm_flags_t vm_flags,
index 47eda0866d52dfc98097d9dceb5246ecff67a6a8..42cb8e5c32ca6ecf73b738bc8ef9ecc6bb12264a 100644 (file)
@@ -5529,7 +5529,11 @@ static ssize_t hugetlb_failed_do_unlock(struct userfaultfd_ctx *ctx,
        return copy_folio_from_user(folio,(const void __user *)src_addr, true);
 }
 
+static int hugetlb_mfill_pte_poison(struct vm_area_struct *dst_vma,
+               unsigned long dst_addr, unsigned long increment);
+
 static const struct vm_uffd_ops hugetlb_uffd_ops = {
+       .poison                 =       hugetlb_mfill_pte_poison,
        .is_dst_valid           =       hugetlb_is_dst_valid,
        .increment              =       hugetlb_mfill_size,
        .failed_do_unlock       =       hugetlb_failed_do_unlock,
index 86db6aa3b8e50c2a0d9f49c9c733b9fbfcc4e290..c1816a582e48370ef030ab14e6300818df440e56 100644 (file)
@@ -5208,6 +5208,7 @@ static int shmem_error_remove_folio(struct address_space *mapping,
 
 #ifdef CONFIG_USERFAULTFD
 static const struct vm_uffd_ops shmem_uffd_ops = {
+       .poison                 =       mfill_atomic_pte_poison,
        .is_dst_valid           =       shmem_is_dst_valid,
        .increment              =       mfill_size,
        .failed_do_unlock       =       uffd_failed_do_unlock,
index a62c0a05cdfa98c74969142cad4de526309b1dce..fd89aebd86b0f4799de4e13219b6c794521d76d0 100644 (file)
@@ -433,9 +433,8 @@ out_release:
 }
 
 /* Handles UFFDIO_POISON for all non-hugetlb VMAs. */
-static int mfill_atomic_pte_poison(struct vm_area_struct *dst_vma,
-                                  unsigned long dst_addr,
-                                  uffd_flags_t flags)
+int mfill_atomic_pte_poison(struct vm_area_struct *dst_vma,
+               unsigned long dst_addr, unsigned long increment)
 {
        int ret;
        struct mm_struct *dst_mm = dst_vma->vm_mm;
@@ -508,6 +507,7 @@ static ssize_t uffd_def_is_dst_valid(struct vm_area_struct *dst_vma,
 
 /* Anon vma ops */
 static const struct vm_uffd_ops default_uffd_ops = {
+       .poison                 = mfill_atomic_pte_poison,
        .is_dst_valid           = uffd_def_is_dst_valid,
        .increment              = mfill_size,
        .failed_do_unlock       = uffd_failed_do_unlock,