hugetlb-userfaultfd-unshare-all-pmds-for-hugetlbfs-when-register-wp.patch removed from -mm tree
The patch titled
Subject: hugetlb/userfaultfd: unshare all pmds for hugetlbfs when register wp
has been removed from the -mm tree. Its filename was
hugetlb-userfaultfd-unshare-all-pmds-for-hugetlbfs-when-register-wp.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: Peter Xu <[email protected]>
Subject: hugetlb/userfaultfd: unshare all pmds for hugetlbfs when register wp
Huge pmd sharing for hugetlbfs is racy with userfaultfd-wp because userfaultfd-wp is always based on pgtable entries, so they cannot be shared.
Walk the hugetlb range and unshare all such mappings if there is, right before UFFDIO_REGISTER will succeed and return to userspace.
This will pair with want_pmd_share() in hugetlb code so that huge pmd sharing is completely disabled for userfaultfd-wp registered range.
---
fs/userfaultfd.c | 4 ++ include/linux/hugetlb.h | 3 ++ mm/hugetlb.c | 51 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+)
fs/userfaultfd.c renamed from fs/userfaultfd.c~hugetlb-userfaultfd-unshare-all-pmds-for-hugetlbfs-when-register-wp +4 -0
@@ -15,6 +15,7 @@#include <linux/sched/signal.h> #include <linux/sched/mm.h> #include <linux/mm.h> +#include <linux/mmu_notifier.h> #include <linux/poll.h> #include <linux/slab.h> #include <linux/seq_file.h>
@@ -1449,6 +1450,9 @@ static int userfaultfd_register(struct u vma->vm_flags = new_flags; vma->vm_userfaultfd_ctx.ctx = ctx; +if (is_vm_hugetlb_page (vma) &&uffd_disable_huge_pmd_share (vma)) +hugetlb_unshare_all_pmds (vma); + skip: prev = vma; start = vma->vm_end;
include/linux/hugetlb.h renamed from include/linux/hugetlb.h~hugetlb-userfaultfd-unshare-all-pmds-for-hugetlbfs-when-register-wp +3 -0
@@ -188,6 +188,7 @@ unsigned long hugetlb_change_protection( unsigned long address, unsigned long end, pgprot_t newprot);bool is_hugetlb_entry_migration (pte_t pte); +void hugetlb_unshare_all_pmds (struct vm_area_struct *vma);#else /* !CONFIG_HUGETLB_PAGE */
@@ -369,6 +370,8 @@ static inline vm_fault_t hugetlb_fault(s return 0; } +static inline void hugetlb_unshare_all_pmds (struct vm_area_struct *vma) { } +#endif /* !CONFIG_HUGETLB_PAGE */ /* * hugepages at page global directory. If arch support
mm/hugetlb.c renamed from mm/hugetlb.c~hugetlb-userfaultfd-unshare-all-pmds-for-hugetlbfs-when-register-wp +51 -0
57 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are
mm-hugetlb-fix-f_seal_future_write.patch mm-hugetlb-fix-cow-where-page-writtable-in-child.patch