Skip to contentSkip to conversation

powerpc-mm-handle-vdso-unmapping-via-close-rather-than-arch_unmap.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Sep 2, 2024

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: powerpc/mm: handle VDSO unmapping via close() rather than arch_unmap()
has been removed from the -mm tree. Its filename was
powerpc-mm-handle-vdso-unmapping-via-close-rather-than-arch_unmap.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Michael Ellerman <[email protected]>
Subject: powerpc/mm: handle VDSO unmapping via close() rather than arch_unmap()
Date: Mon, 12 Aug 2024 18:26:03 +1000

Add a close() callback to the VDSO special mapping to handle unmapping of the VDSO. That will make it possible to remove the arch_unmap() hook entirely in a subsequent patch.

---

 arch/powerpc/include/asm/mmu_context.h |    4 ----
 arch/powerpc/kernel/vdso.c             |   17 +++++++++++++++++
 2 files changed, 17 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/mmu_context.h renamed from arch/powerpc/include/asm/mmu_context.h~powerpc-mm-handle-vdso-unmapping-via-close-rather-than-arch_unmap +0 -4
@@ -263,10 +263,6 @@ extern void arch_exit_mmap(struct mm_str
 static inline void arch_unmap(struct mm_struct *mm,
 			      unsigned long start, unsigned long end)
 {
-	unsigned long vdso_base = (unsigned long)mm->context.vdso;
-
-	if (start <= vdso_base && vdso_base < end)
-		mm->context.vdso = NULL;
 }
 
 #ifdef CONFIG_PPC_MEM_KEYS
arch/powerpc/kernel/vdso.c renamed from arch/powerpc/kernel/vdso.c~powerpc-mm-handle-vdso-unmapping-via-close-rather-than-arch_unmap +17 -0
@@ -81,6 +81,21 @@ static int vdso64_mremap(const struct vm
 	return vdso_mremap(sm, new_vma, &vdso64_end - &vdso64_start);
 }
 
+static void vdso_close(const struct vm_special_mapping *sm, struct vm_area_struct *vma)
+{
+	struct mm_struct *mm = vma->vm_mm;
+
+	/*
+	 * close() is called for munmap() but also for mremap(). In the mremap()
+	 * case the vdso pointer has already been updated by the mremap() hook
+	 * above, so it must not be set to NULL here.
+	 */
+	if (vma->vm_start != (unsigned long)mm->context.vdso)
+		return;
+
+	mm->context.vdso = NULL;
+}
+
 static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,
 			     struct vm_area_struct *vma, struct vm_fault *vmf);
 
@@ -92,11 +107,13 @@ static struct vm_special_mapping vvar_sp
 static struct vm_special_mapping vdso32_spec __ro_after_init = {
 	.name = "[vdso]",
 	.mremap = vdso32_mremap,
+	.close = vdso_close,
 };
 
 static struct vm_special_mapping vdso64_spec __ro_after_init = {
 	.name = "[vdso]",
 	.mremap = vdso64_mremap,
+	.close = vdso_close,
 };
 
 #ifdef CONFIG_TIME_NS

_

Patches currently in -mm which might be from [email protected] are