Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6002443ybl; Tue, 14 Jan 2020 19:37:47 -0800 (PST) X-Google-Smtp-Source: APXvYqwJ5xmCnFxdPpG/kPD2lhces6JdM8RnMrTM7Wie8zzak6jyEZyDyEHMX2zG7CrQ959/CoUt X-Received: by 2002:a05:6830:22e2:: with SMTP id t2mr1319806otc.129.1579059466792; Tue, 14 Jan 2020 19:37:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579059466; cv=none; d=google.com; s=arc-20160816; b=FFz4VNodu8wyiEX+lm8sxbpGTaui5kFqWl3Ha5XYrHTLEgGREu/spEryhb5ZCVMp0I 5yF/AadYPa0uUQXRyCL5j9sIbd0kgqZCdbDdJl4UBPUeErcV3kFUv400M9RQAyadla88 9LnSHz1HA9+fGXYT1IRq0eyminTuU0QVc1UMMenT6giHZqIAefHVrBopSfb97yCDqztL TPTCj9s+MbHP6t1ibjt485xEaYG1s47L4CIRiJaEkVY1h3KI0Vewpi4Z+acP5j5y1LYd PeVKOtZlOJa9oEWyoLpD5rVzxYCwZAhz3XqixJf4mb4vv1pluDByDX/ARIMH1JMYEOEg Wp7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=Dw9RZK+/HVUrztEu7gVPE0ZxHPMhjcjd9qAOgk5/pKk=; b=JRkJYDg9L50+chNI6CszzQIGFhsIfROyMI6aYQ98Jqm+/L+kpvFmre12T17q5YKMiH 1CboLqRnhxJYEMz5bEUwsgw7mV2sFxTPX+dlQxS0PyGoz+azR3XriDErUsug4D9Q0xhU zqSBKFZ82I1uYPWnlDm8Zzlf4Q+dCU6sp68Y+a2bp0VqCKaQ6sMIR9rmD9Q0bx+BtxfT 0kqejmmtKzS8CNGtTu/Y8UNyESKiWdUFanKsflBzAxG8JJwsjrKugf2EkCvsXYkLoG2d bo1r45x1cJPeIaqrPQ4bh4R2h5c3Q7RWzTYs1XM/ZGZ/ajid8R95rYumkZKDLDbiZo3w bXew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d21si8662374oic.168.2020.01.14.19.37.32; Tue, 14 Jan 2020 19:37:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728899AbgAODfS (ORCPT + 99 others); Tue, 14 Jan 2020 22:35:18 -0500 Received: from mail.loongson.cn ([114.242.206.163]:59598 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728884AbgAODfS (ORCPT ); Tue, 14 Jan 2020 22:35:18 -0500 Received: from localhost.cn (unknown [10.40.23.12]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dx39lkiB5e_EQFAA--.3S2; Wed, 15 Jan 2020 11:35:01 +0800 (CST) From: Guoyun Sun To: Ralf Baechle , Paul Burton , Allison Randal , Thomas Gleixner , Greg Kroah-Hartman Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Guoyun Sun Subject: [PATCH V2] mips/vdso: Support mremap() for vDSO Date: Wed, 15 Jan 2020 11:35:00 +0800 Message-Id: <1579059300-6636-1-git-send-email-sunguoyun@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf9Dx39lkiB5e_EQFAA--.3S2 X-Coremail-Antispam: 1UD129KBjvJXoW7trWfWFWrAr1xWw4fGFyrCrg_yo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org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 \n"); fprintf(out_file, "#include \n"); fprintf(out_file, "#include \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 */ -- 2.1.0