Linux-MIPS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH V2] mips/vdso: Support mremap() for vDSO
@ 2020-01-15  3:35 Guoyun Sun
  2020-01-15 18:59 ` Paul Burton
  0 siblings, 1 reply; 2+ messages in thread
From: Guoyun Sun @ 2020-01-15  3:35 UTC (permalink / raw)
  To: Ralf Baechle, Paul Burton, Allison Randal, Thomas Gleixner,
	Greg Kroah-Hartman
  Cc: linux-mips, linux-kernel, Guoyun Sun

vDSO VMA address is saved in mm_context for the purpose of using
restorer from vDSO page to return to userspace after signal handling.

In Checkpoint Restore in Userspace (CRIU) project we place vDSO VMA
on restore back to the place where it was on the dump.

Make vDSO code track the VMA address by supplying .mremap() fops
the same way it's done for x86 and arm by:
commit b059a453b1cf ("x86/vdso: Add mremap hook to vm_special_mapping")
commit 739586951b8a ("arm64/vdso: Support mremap() for vDSO").

Signed-off-by: Guoyun Sun <sunguoyun@loongson.cn>
---
 arch/mips/vdso/genvdso.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/mips/vdso/genvdso.c b/arch/mips/vdso/genvdso.c
index b66b6b1..be57b83 100644
--- a/arch/mips/vdso/genvdso.c
+++ b/arch/mips/vdso/genvdso.c
@@ -251,6 +251,18 @@ int main(int argc, char **argv)
 	fprintf(out_file, "#include <linux/linkage.h>\n");
 	fprintf(out_file, "#include <linux/mm.h>\n");
 	fprintf(out_file, "#include <asm/vdso.h>\n");
+	fprintf(out_file, "static int vdso_mremap(\n");
+	fprintf(out_file, "	const struct vm_special_mapping *sm,\n");
+	fprintf(out_file, "	struct vm_area_struct *new_vma)\n");
+	fprintf(out_file, "{\n");
+	fprintf(out_file, "	unsigned long new_size =\n");
+	fprintf(out_file, "	new_vma->vm_end - new_vma->vm_start;\n");
+	fprintf(out_file, "	if (vdso_image.size != new_size)\n");
+	fprintf(out_file, "		return -EINVAL;\n");
+	fprintf(out_file, "	current->mm->context.vdso =\n");
+	fprintf(out_file, "	(void __user *)(new_vma->vm_start);\n");
+	fprintf(out_file, "	return 0;\n");
+	fprintf(out_file, "}\n");
 
 	/* Write out the stripped VDSO data. */
 	fprintf(out_file,
@@ -275,6 +287,7 @@ int main(int argc, char **argv)
 	fprintf(out_file, "\t.mapping = {\n");
 	fprintf(out_file, "\t\t.name = \"[vdso]\",\n");
 	fprintf(out_file, "\t\t.pages = vdso_pages,\n");
+	fprintf(out_file, "\t\t.mremap = vdso_mremap,\n");
 	fprintf(out_file, "\t},\n");
 
 	/* Calculate and write symbol offsets to <output file> */
-- 
2.1.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH V2] mips/vdso: Support mremap() for vDSO
  2020-01-15  3:35 [PATCH V2] mips/vdso: Support mremap() for vDSO Guoyun Sun
@ 2020-01-15 18:59 ` Paul Burton
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Burton @ 2020-01-15 18:59 UTC (permalink / raw)
  To: Guoyun Sun
  Cc: Ralf Baechle, Paul Burton, Allison Randal, Thomas Gleixner,
	Greg Kroah-Hartman, linux-mips, linux-kernel, Guoyun Sun,
	linux-mips

Hello,

Guoyun Sun wrote:
> vDSO VMA address is saved in mm_context for the purpose of using
> restorer from vDSO page to return to userspace after signal handling.
> 
> In Checkpoint Restore in Userspace (CRIU) project we place vDSO VMA
> on restore back to the place where it was on the dump.
> 
> Make vDSO code track the VMA address by supplying .mremap() fops
> the same way it's done for x86 and arm by:
> commit b059a453b1cf ("x86/vdso: Add mremap hook to vm_special_mapping")
> commit 739586951b8a ("arm64/vdso: Support mremap() for vDSO").

Applied to mips-next.

> commit ad1df95419cc
> https://git.kernel.org/mips/c/ad1df95419cc
> 
> Signed-off-by: Guoyun Sun <sunguoyun@loongson.cn>
> Signed-off-by: Paul Burton <paulburton@kernel.org>

Thanks,
    Paul

[ This message was auto-generated; if you believe anything is incorrect
  then please email paulburton@kernel.org to report it. ]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15  3:35 [PATCH V2] mips/vdso: Support mremap() for vDSO Guoyun Sun
2020-01-15 18:59 ` Paul Burton

Linux-MIPS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mips/0 linux-mips/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mips linux-mips/ https://lore.kernel.org/linux-mips \
		linux-mips@vger.kernel.org
	public-inbox-index linux-mips

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-mips


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git