@@ -5457,6 +5457,22 @@ static vm_fault_t hugetlb_vm_op_fault(struct vm_fault *vmf)
54575457 return 0 ;
54585458}
54595459
5460+ #ifdef CONFIG_USERFAULTFD
5461+ static const vm_uffd_ops hugetlb_uffd_ops = {
5462+ .uffd_features = __VM_UFFD_FLAGS ,
5463+ /* _UFFDIO_ZEROPAGE not supported */
5464+ .uffd_ioctls = BIT (_UFFDIO_COPY ) |
5465+ BIT (_UFFDIO_WRITEPROTECT ) |
5466+ BIT (_UFFDIO_CONTINUE ) |
5467+ BIT (_UFFDIO_POISON ),
5468+ /*
5469+ * Hugetlbfs still has its own hard-coded handler in userfaultfd,
5470+ * due to limitations similar to vm_operations_struct.fault().
5471+ * TODO: generalize it to use the API functions.
5472+ */
5473+ };
5474+ #endif
5475+
54605476/*
54615477 * When a new function is introduced to vm_operations_struct and added
54625478 * to hugetlb_vm_ops, please consider adding the function to shm_vm_ops.
@@ -5470,6 +5486,9 @@ const struct vm_operations_struct hugetlb_vm_ops = {
54705486 .close = hugetlb_vm_op_close ,
54715487 .may_split = hugetlb_vm_op_split ,
54725488 .pagesize = hugetlb_vm_op_pagesize ,
5489+ #ifdef CONFIG_USERFAULTFD
5490+ .userfaultfd_ops = & hugetlb_uffd_ops ,
5491+ #endif
54735492};
54745493
54755494static pte_t make_huge_pte (struct vm_area_struct * vma , struct folio * folio ,
0 commit comments