Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4797904ybl; Mon, 13 Jan 2020 21:14:57 -0800 (PST) X-Google-Smtp-Source: APXvYqy7FFuVI8LQegqoi6Jh8kuZmBDWW/4SwoT2Zw+PfK2AHU7YYzyJP8I4tyhHR/IaqNu+2UPv X-Received: by 2002:aca:220c:: with SMTP id b12mr14998976oic.55.1578978897254; Mon, 13 Jan 2020 21:14:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578978897; cv=none; d=google.com; s=arc-20160816; b=FqLj19GPl7nUjVXa8foiiaEWmVuhSC3Zk+f15b7t1p1pQB8HFzb4HuEXKH47nHLmb5 +RK/2z3Kmb1YHa/rRnEbGmo8vgFQ5TCXg2y8VhDcv5v2Q9Z321k1Q6HnLzXf0CuHIWCI E2pW2r+Rzj1WOQ+L2aSURiABMJftMO0BtKuoQKDP1p1PMY3orIEGvEGMoLC6IcYHcNJb hFHtq1aJ9yGkBZTUSOK2iH5YwpWEojtJzLAAo0iDvCSIdUCVuoaePIDIJxzM1HFJXIjw Ep1xK4KkR6/g2kBmPAFBgPEzPHJcaiM6LeUB1Ia0Jdr6Zuu9M+pUuSdK6/O5iFFenlWW xeFg== 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=91etFspi3cnXs3Aw9N6Fb5PDr8LdebILqWVr+d6DUeM=; b=OoYKxfBzfizqSN+Uh2ZAEkFmhI9JyqGxqvpX2kgFcEtkMXh90Spdw/Gdzm4GsMPUWz Q7+tmwcrODB+jGV9AznAi8bCuFyt8wuUuyK9iTlx30+/M1gK4wErSLXh+k2MvtFphn2e GATUZ4mADcMXbCvrG9xWXQg3LBiHXxSMwQdCF7RGQOvOn1I1pHiRJ62Bo00zimyNNd+f l8VgBFeMWhPt/2fK0emg52X+ndqdsZOY+135zWIxeJCp/AGkQiFySXc60ulDbhhe571D ZhTvFLiz9CBFDdrM7SFxLvSBYMXmDWtxZOwybO67GUoAFuhYiwDBHvybCvDfQ59qC0XN 0xtg== 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 s6si7710375otp.126.2020.01.13.21.14.45; Mon, 13 Jan 2020 21:14:57 -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 S1726495AbgANFNv (ORCPT + 99 others); Tue, 14 Jan 2020 00:13:51 -0500 Received: from mail.loongson.cn ([114.242.206.163]:34640 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725306AbgANFNv (ORCPT ); Tue, 14 Jan 2020 00:13:51 -0500 Received: from localhost.cn (unknown [10.40.23.12]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxj2j4TR1e4dYEAA--.9S2; Tue, 14 Jan 2020 13:13:29 +0800 (CST) From: Guoyun Sun To: Paul Burton , Ralf Baechle , Thomas Gleixner , Greg Kroah-Hartman , Vincenzo Frascino , Allison Randal Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Guoyun Sun Subject: [PATCH] mips/vdso: Support mremap() for vDSO Date: Tue, 14 Jan 2020 13:13:28 +0800 Message-Id: <1578978808-18633-1-git-send-email-sunguoyun@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf9Dxj2j4TR1e4dYEAA--.9S2 X-Coremail-Antispam: 1UD129KBjvJXoWxW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w3hr1x0qxorr0wxvrqhubq/ Sender: linux-kernel-owner@vger.kernel.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/kernel/vdso.c | 22 ++++++++++++++++++++++ arch/mips/vdso/genvdso.c | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c index bc35f84..eac3982 100644 --- a/arch/mips/kernel/vdso.c +++ b/arch/mips/kernel/vdso.c @@ -38,6 +38,28 @@ static struct vm_special_mapping vdso_vvar_mapping = { .pages = no_pages, }; +int vdso_mremap(const struct vm_special_mapping *sm, + struct vm_area_struct *new_vma) +{ + unsigned long new_size = new_vma->vm_end - new_vma->vm_start; + +#ifdef CONFIG_MIPS32_O32 + if (vdso_image_o32.size != new_size) + return -EINVAL; +#endif + +#ifdef CONFIG_MIPS32_N32 + if (vdso_image_n32.size != new_size) + return -EINVAL; +#endif + + if (vdso_image.size != new_size) + return -EINVAL; + + current->mm->context.vdso = (void __user *)(new_vma->vm_start); + return 0; +} + static void __init init_vdso_image(struct mips_vdso_image *image) { unsigned long num_pages, i; diff --git a/arch/mips/vdso/genvdso.c b/arch/mips/vdso/genvdso.c index b66b6b1..50ea516 100644 --- a/arch/mips/vdso/genvdso.c +++ b/arch/mips/vdso/genvdso.c @@ -251,6 +251,10 @@ int main(int argc, char **argv) fprintf(out_file, "#include \n"); fprintf(out_file, "#include \n"); fprintf(out_file, "#include \n"); + fprintf(out_file, "\n"); + fprintf(out_file, "extern int vdso_mremap(\n"); + fprintf(out_file, " const struct vm_special_mapping *sm,\n"); + fprintf(out_file, " struct vm_area_struct *new_vma);\n\n"); /* Write out the stripped VDSO data. */ fprintf(out_file, @@ -275,6 +279,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