From: Liam R. Howlett Date: Fri, 24 Oct 2025 02:59:32 +0000 (-0400) Subject: mm/userfaultfd: Align poison function definitions for uffd_ops X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=5a43793420facb5d0d7896c379d26d2a6100b248;p=users%2Fjedix%2Flinux-maple.git mm/userfaultfd: Align poison function definitions for uffd_ops 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 --- diff --git a/include/linux/userfaultfd_k.h b/include/linux/userfaultfd_k.h index d3b9d8adf32d..fee5a904fbd0 100644 --- a/include/linux/userfaultfd_k.h +++ b/include/linux/userfaultfd_k.h @@ -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, diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 47eda0866d52..42cb8e5c32ca 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -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, diff --git a/mm/shmem.c b/mm/shmem.c index 86db6aa3b8e5..c1816a582e48 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -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, diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index a62c0a05cdfa..fd89aebd86b0 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -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,