Unverified Commit ad1df954 authored by Guoyun Sun's avatar Guoyun Sun Committed by Paul Burton
Browse files

mips/vdso: Support mremap() for vDSO



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 b059a453 ("x86/vdso: Add mremap hook to vm_special_mapping")
commit 73958695 ("arm64/vdso: Support mremap() for vDSO").

Signed-off-by: default avatarGuoyun Sun <sunguoyun@loongson.cn>
Signed-off-by: default avatarPaul Burton <paulburton@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Allison Randal <allison@lohutok.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-mips@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
parent e8c19201
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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> */