powerpc/vdso: Provide vdso_remap()
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Sun, 27 Sep 2020 09:16:28 +0000 (09:16 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 3 Dec 2020 14:01:16 +0000 (01:01 +1100)
Provide vdso_remap() through _install_special_mapping() and
drop arch_remap().

This adds a test of the size and returns -EINVAL if the size
is not correct.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/373c66f768fa9cc8890f3b55462209a98c522326.1601197618.git.christophe.leroy@csgroup.eu
arch/powerpc/include/asm/mm-arch-hooks.h [deleted file]
arch/powerpc/kernel/vdso.c

diff --git a/arch/powerpc/include/asm/mm-arch-hooks.h b/arch/powerpc/include/asm/mm-arch-hooks.h
deleted file mode 100644 (file)
index dce274b..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Architecture specific mm hooks
- *
- * Copyright (C) 2015, IBM Corporation
- * Author: Laurent Dufour <ldufour@linux.vnet.ibm.com>
- */
-
-#ifndef _ASM_POWERPC_MM_ARCH_HOOKS_H
-#define _ASM_POWERPC_MM_ARCH_HOOKS_H
-
-static inline void arch_remap(struct mm_struct *mm,
-                             unsigned long old_start, unsigned long old_end,
-                             unsigned long new_start, unsigned long new_end)
-{
-       /*
-        * mremap() doesn't allow moving multiple vmas so we can limit the
-        * check to old_start == vdso_base.
-        */
-       if (old_start == mm->context.vdso_base)
-               mm->context.vdso_base = new_start;
-}
-#define arch_remap arch_remap
-
-#endif /* _ASM_POWERPC_MM_ARCH_HOOKS_H */
index 67fb4c7..2b97575 100644 (file)
@@ -115,13 +115,37 @@ struct lib64_elfinfo
        unsigned long   text;
 };
 
+static int vdso_mremap(const struct vm_special_mapping *sm, struct vm_area_struct *new_vma,
+                      unsigned long text_size)
+{
+       unsigned long new_size = new_vma->vm_end - new_vma->vm_start;
+
+       if (new_size != text_size + PAGE_SIZE)
+               return -EINVAL;
+
+       current->mm->context.vdso_base = new_vma->vm_start;
+
+       return 0;
+}
+
+static int vdso32_mremap(const struct vm_special_mapping *sm, struct vm_area_struct *new_vma)
+{
+       return vdso_mremap(sm, new_vma, &vdso32_end - &vdso32_start);
+}
+
+static int vdso64_mremap(const struct vm_special_mapping *sm, struct vm_area_struct *new_vma)
+{
+       return vdso_mremap(sm, new_vma, &vdso64_end - &vdso64_start);
+}
 
 static struct vm_special_mapping vdso32_spec __ro_after_init = {
        .name = "[vdso]",
+       .mremap = vdso32_mremap,
 };
 
 static struct vm_special_mapping vdso64_spec __ro_after_init = {
        .name = "[vdso]",
+       .mremap = vdso64_mremap,
 };
 
 /*