Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

powerpc/mm: handle VDSO unmapping via close() rather than arch_unmap()

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.

Link: https://lkml.kernel.org/r/20240812082605.743814-2-mpe@ellerman.id.au
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Jeff Xu <jeffxu@google.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Pedro Falcato <pedro.falcato@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Michael Ellerman and committed by
Andrew Morton
5463bafa 223febc6

+17 -4
-4
arch/powerpc/include/asm/mmu_context.h
··· 263 263 static inline void arch_unmap(struct mm_struct *mm, 264 264 unsigned long start, unsigned long end) 265 265 { 266 - unsigned long vdso_base = (unsigned long)mm->context.vdso; 267 - 268 - if (start <= vdso_base && vdso_base < end) 269 - mm->context.vdso = NULL; 270 266 } 271 267 272 268 #ifdef CONFIG_PPC_MEM_KEYS
+17
arch/powerpc/kernel/vdso.c
··· 81 81 return vdso_mremap(sm, new_vma, &vdso64_end - &vdso64_start); 82 82 } 83 83 84 + static void vdso_close(const struct vm_special_mapping *sm, struct vm_area_struct *vma) 85 + { 86 + struct mm_struct *mm = vma->vm_mm; 87 + 88 + /* 89 + * close() is called for munmap() but also for mremap(). In the mremap() 90 + * case the vdso pointer has already been updated by the mremap() hook 91 + * above, so it must not be set to NULL here. 92 + */ 93 + if (vma->vm_start != (unsigned long)mm->context.vdso) 94 + return; 95 + 96 + mm->context.vdso = NULL; 97 + } 98 + 84 99 static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, 85 100 struct vm_area_struct *vma, struct vm_fault *vmf); 86 101 ··· 107 92 static struct vm_special_mapping vdso32_spec __ro_after_init = { 108 93 .name = "[vdso]", 109 94 .mremap = vdso32_mremap, 95 + .close = vdso_close, 110 96 }; 111 97 112 98 static struct vm_special_mapping vdso64_spec __ro_after_init = { 113 99 .name = "[vdso]", 114 100 .mremap = vdso64_mremap, 101 + .close = vdso_close, 115 102 }; 116 103 117 104 #ifdef CONFIG_TIME_NS