linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH v1 6/9] powerpc/vdso: Provide vdso_remap()
Date: Tue, 25 Aug 2020 13:54:04 +0000 (UTC)	[thread overview]
Message-ID: <09497ca1607b62029e46b321bac0732864503323.1598363608.git.christophe.leroy@csgroup.eu> (raw)
In-Reply-To: <df48ed76cf8a756a7f97ed42a1a39d0a404014bc.1598363608.git.christophe.leroy@csgroup.eu>

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>
---
 arch/powerpc/include/asm/mm-arch-hooks.h | 25 ---------------------
 arch/powerpc/kernel/vdso.c               | 28 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 25 deletions(-)
 delete mode 100644 arch/powerpc/include/asm/mm-arch-hooks.h

diff --git a/arch/powerpc/include/asm/mm-arch-hooks.h b/arch/powerpc/include/asm/mm-arch-hooks.h
deleted file mode 100644
index dce274be824a..000000000000
--- a/arch/powerpc/include/asm/mm-arch-hooks.h
+++ /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 */
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index 4ccfc0dc96b5..b9270923452e 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -114,13 +114,41 @@ struct lib64_elfinfo
 	unsigned long	text;
 };
 
+static int vdso_mremap(unsigned long vdso_pages,
+		       const struct vm_special_mapping *sm,
+		       struct vm_area_struct *new_vma)
+{
+	unsigned long new_size = new_vma->vm_end - new_vma->vm_start;
+	unsigned long vdso_size = (vdso_pages + 1) << PAGE_SHIFT;
+
+	if (new_size != vdso_size)
+		return -EINVAL;
+
+	current->mm->context.vdso_base = (unsigned long)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(vdso32_pages, sm, new_vma);
+}
+
+static int vdso64_mremap(const struct vm_special_mapping *sm,
+			 struct vm_area_struct *new_vma)
+{
+	return vdso_mremap(vdso64_pages, sm, new_vma);
+}
 
 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,
 };
 
 /*
-- 
2.25.0


  parent reply	other threads:[~2020-08-25 13:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-25 13:53 [PATCH v1 1/9] powerpc/vdso: Remove BUG_ON() in vdso_init() Christophe Leroy
2020-08-25 13:54 ` [PATCH v1 2/9] powerpc/vdso: Remove get_page() in vdso_pagelist initialization Christophe Leroy
2020-08-25 13:54 ` [PATCH v1 3/9] powerpc/vdso: Remove NULL termination element in vdso_pagelist Christophe Leroy
2020-08-25 13:54 ` [PATCH v1 4/9] powerpc/vdso: Remove unnecessary ifdefs in vdso_pagelist initialization Christophe Leroy
2020-08-26 14:58   ` Michael Ellerman
2020-08-26 15:21     ` Christophe Leroy
2020-08-27  6:47     ` Christophe Leroy
2020-08-27 13:19       ` Michael Ellerman
2020-08-28  5:40         ` Christophe Leroy
2020-08-28  5:46           ` Christophe Leroy
2020-08-25 13:54 ` [PATCH v1 5/9] powerpc/vdso: move to _install_special_mapping() and remove arch_vma_name() Christophe Leroy
2020-08-25 13:54 ` Christophe Leroy [this message]
2020-08-25 13:54 ` [PATCH v1 7/9] powerpc/vdso: Move vdso datapage up front Christophe Leroy
2020-08-25 13:54 ` [PATCH v1 8/9] powerpc/vdso: Remove __kernel_datapage_offset and simplify __get_datapage() Christophe Leroy
2020-08-25 13:54 ` [PATCH v1 9/9] powerpc/vdso: Remove unused \tmp param in __get_datapage() Christophe Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=09497ca1607b62029e46b321bac0732864503323.1598363608.git.christophe.leroy@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).