Skip to contentSkip to conversation

hugetlb-userfaultfd-unshare-all-pmds-for-hugetlbfs-when-register-wp.patch removed from -mm tree

merged [email protected] 1 participant 1 message May 8, 2021

lore
Share & tools
lore

[email protected]

author tree notice Applied
#0 lore raw

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.

Cc Peter Xu <[email protected]>
Cc Andrea Arcangeli <[email protected]>
Cc Axel Rasmussen <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Kirill A. Shutemov <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Adam Ruprecht <[email protected]>
Cc Alexander Viro <[email protected]>
Cc Alexey Dobriyan <[email protected]>
Cc Anshuman Khandual <[email protected]>
Cc Cannon Matthews <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Chinwen Chang <[email protected]>
Cc David Rientjes <[email protected]>
Cc "Dr . David Alan Gilbert" <[email protected]>
Cc Huang Ying <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jann Horn <[email protected]>
Cc Jerome Glisse <[email protected]>
Cc Lokesh Gidra <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc "Michal Koutn" <[email protected]>
Cc Michel Lespinasse <[email protected]>
Cc Mina Almasry <[email protected]>
Cc Nicholas Piggin <[email protected]>
Cc Oliver Upton <[email protected]>
Cc Shaohua Li <[email protected]>
Cc Shawn Anastasio <[email protected]>
Cc Steven Price <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Vlastimil Babka <[email protected]>

---

 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