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.

mm: add optional close() to struct vm_special_mapping

Add an optional close() callback to struct vm_special_mapping. It will be
used, by powerpc at least, to handle unmapping of the VDSO.

Although support for unmapping the VDSO was initially added for CRIU[1],
it is not desirable to guard that support behind
CONFIG_CHECKPOINT_RESTORE.

There are other known users of unmapping the VDSO which are not related to
CRIU, eg. Valgrind [2] and void-ship [3].

The powerpc arch_unmap() hook has been in place for ~9 years, with no
ifdef, so there may be other unknown users that have come to rely on
unmapping the VDSO. Even if the code was behind an ifdef, major distros
enable CHECKPOINT_RESTORE so users may not realise unmapping the VDSO
depends on that configuration option.

It's also undesirable to have such core mm behaviour behind a relatively
obscure CONFIG option.

Longer term the unmap behaviour should be standardised across
architectures, however that is complicated by the fact the VDSO pointer is
stored differently across architectures. There was a previous attempt to
unify that handling [4], which could be revived.

See [5] for further discussion.

[1]: commit 83d3f0e90c6c ("powerpc/mm: tracking vDSO remap")
[2]: https://sourceware.org/git/?p=valgrind.git;a=commit;h=3a004915a2cbdcdebafc1612427576bf3321eef5
[3]: https://github.com/insanitybit/void-ship
[4]: https://lore.kernel.org/lkml/20210611180242.711399-17-dima@arista.com/
[5]: https://lore.kernel.org/linuxppc-dev/shiq5v3jrmyi6ncwke7wgl76ojysgbhrchsk32q4lbx2hadqqc@kzyy2igem256

Link: https://lkml.kernel.org/r/20240812082605.743814-1-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
223febc6 c36be0cd

+9
+3
include/linux/mm_types.h
··· 1324 1324 1325 1325 int (*mremap)(const struct vm_special_mapping *sm, 1326 1326 struct vm_area_struct *new_vma); 1327 + 1328 + void (*close)(const struct vm_special_mapping *sm, 1329 + struct vm_area_struct *vma); 1327 1330 }; 1328 1331 1329 1332 enum tlb_flush_reason {
+6
mm/mmap.c
··· 2045 2045 static vm_fault_t special_mapping_fault(struct vm_fault *vmf); 2046 2046 2047 2047 /* 2048 + * Close hook, called for unmap() and on the old vma for mremap(). 2049 + * 2048 2050 * Having a close hook prevents vma merging regardless of flags. 2049 2051 */ 2050 2052 static void special_mapping_close(struct vm_area_struct *vma) 2051 2053 { 2054 + const struct vm_special_mapping *sm = vma->vm_private_data; 2055 + 2056 + if (sm->close) 2057 + sm->close(sm, vma); 2052 2058 } 2053 2059 2054 2060 static const char *special_mapping_name(struct vm_area_struct *vma)