From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10AB2C433E1 for ; Wed, 24 Jun 2020 08:35:30 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D574120B80 for ; Wed, 24 Jun 2020 08:35:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kv3iXk9G"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="inED/Qfo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D574120B80 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=othkPH0VyjkRJ4yiXkTHwgG7ijx1OmsvMAvXByPxWVw=; b=kv3iXk9Gu1u0xt1DJ3focJW7kr rpm5VbmnKNIbcfxf70gkLX86IA8XPfNdmQEOmyrLeoklVdsHxdzeLmZ5QCP4aEq2sUlPLM37WJ3Qb qfEXTNmmL8dr02W2LI5Bp9f2deaqMayR9uPXkwbm5w100qbT7BE1e3SLl8LRPyaLQVtdYOUOkmkSZ Vl0/biJseXL1OtIsXosFC7eEdm25ZPQy2jzEutRjPXfiFqDhIYeUZJ8XfTSr1/lBpg7YQccREpdND rnKkSbF0Hu7x98NkJ7gm3gKKVcQsS+NXvV0VZlBYAR8cq1fboL3aH829Z3IuUxEx6pJVb5ie4+UoV NhpY9U5Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jo0qd-0008H7-39; Wed, 24 Jun 2020 08:33:35 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jo0qW-0008EZ-3m for linux-arm-kernel@lists.infradead.org; Wed, 24 Jun 2020 08:33:29 +0000 Received: by mail-pl1-x642.google.com with SMTP id k1so792116pls.2 for ; Wed, 24 Jun 2020 01:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cTWQs0HlakIx1EXTUfvYi5OI/+C9xhCIK6shQ1G+dgY=; b=inED/QfocfJvVgmnsagLvNK5ZybNoQfR9wcp/QL5AKj1ixNZ692lqxPsJgkPlmVhCV RxHfNyutt843L3+W25uaXmcm6QemN6vSqsKCYNMUd2tFxW+7GQxyxuUOt1kE4WgQXVCy nTGRdiMPJKI6fo88SHtq7uundZwirhbHXYpXxBY+NjcVFnxQ/CfHfSDJ0h3j9pNhk+zo Ir5RFvfHLfm8yUw2fomRWlQjstUOYLzHu3k3nsB1njibfYVh/unKZPFHl9QEkTaX4WTi uqK05p2t51hl0+lJ1wA4PDTwr47mWKP86z4wuVT2o/MtAdQz6g108jzUHQ+FmBAA5oEn EOdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cTWQs0HlakIx1EXTUfvYi5OI/+C9xhCIK6shQ1G+dgY=; b=IWEpX9qjWIXXD72dLNPPj2qRHi8ACVn5Zrh8BJ7y3El9nGv/36j1XiG3x+tBwm5KyN CYYyCMVSB/ygI0ejn0cFmz1M6rRnAiaPgWHC8mmZJZLatN62VFi/UQIPGR5eWX6Elmr1 y3Qa8y0TRNJwCtRbE5Tz0YKtKZ+W9YNl4cQWLw4QX+mfcdFCIsatpe2QQ8R1HtX+O0Gk UzUFPRPTTB+o7hL3sBKeTvVxQMjETm01z3CiLNAFF2E1NrsdA5FngPUb0LelWxjwdYdX iXDG9UCKw2ieSutTqEjLwDKY259UB1/IAxUmI1y+NbWJDsTz94AVX7XvLG7GJKMriTJa vlZg== X-Gm-Message-State: AOAM5321UWuP5G85rtC5wsW2lsxR3TCI7+vE1TpkHImN0U8YWlyx+aQE PpnKpj5dvxKWj8wMhuUaU7Q= X-Google-Smtp-Source: ABdhPJyVDRj2hXj+Fjq+I7TAU5NAayzGzoSlFOSJqBtvHZV712+kCKfrf3ZS9ZQpU7i/+kjn7+hteA== X-Received: by 2002:a17:90a:b30d:: with SMTP id d13mr27089006pjr.181.1592987604529; Wed, 24 Jun 2020 01:33:24 -0700 (PDT) Received: from laptop.hsd1.wa.comcast.net ([2601:600:9b7f:872e:a655:30fb:7373:c762]) by smtp.gmail.com with ESMTPSA id g17sm4558614pju.11.2020.06.24.01.33.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 01:33:24 -0700 (PDT) From: Andrei Vagin To: Catalin Marinas , Will Deacon , Mark Rutland Subject: [PATCH 1/6] arm64/vdso: use the fault callback to map vvar pages Date: Wed, 24 Jun 2020 01:33:16 -0700 Message-Id: <20200624083321.144975-2-avagin@gmail.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200624083321.144975-1-avagin@gmail.com> References: <20200624083321.144975-1-avagin@gmail.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Safonov , linux-kernel@vger.kernel.org, Andrei Vagin , Thomas Gleixner , Vincenzo Frascino , Christian Brauner , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently the vdso has no awareness of time namespaces, which may apply distinct offsets to processes in different namespaces. To handle this within the vdso, we'll need to expose a per-namespace data page. As a preparatory step, this patch separates the vdso data page from the code pages, and has it faulted in via its own fault callback. Subsquent patches will extend this to support distinct pages per time namespace. The vvar vma has to be installed with the VM_PFNMAP flag to handle faults via its vma fault callback. Reviewed-by: Vincenzo Frascino Reviewed-by: Dmitry Safonov Signed-off-by: Andrei Vagin --- arch/arm64/kernel/vdso.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index 4e016574bd91..7c4620451fa5 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -107,29 +107,32 @@ static int __vdso_init(enum vdso_abi abi) vdso_info[abi].vdso_code_start) >> PAGE_SHIFT; - /* Allocate the vDSO pagelist, plus a page for the data. */ - vdso_pagelist = kcalloc(vdso_info[abi].vdso_pages + 1, + vdso_pagelist = kcalloc(vdso_info[abi].vdso_pages, sizeof(struct page *), GFP_KERNEL); if (vdso_pagelist == NULL) return -ENOMEM; - /* Grab the vDSO data page. */ - vdso_pagelist[0] = phys_to_page(__pa_symbol(vdso_data)); - - /* Grab the vDSO code pages. */ pfn = sym_to_pfn(vdso_info[abi].vdso_code_start); for (i = 0; i < vdso_info[abi].vdso_pages; i++) - vdso_pagelist[i + 1] = pfn_to_page(pfn + i); + vdso_pagelist[i] = pfn_to_page(pfn + i); - vdso_info[abi].dm->pages = &vdso_pagelist[0]; - vdso_info[abi].cm->pages = &vdso_pagelist[1]; + vdso_info[abi].cm->pages = vdso_pagelist; return 0; } +static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, + struct vm_area_struct *vma, struct vm_fault *vmf) +{ + if (vmf->pgoff == 0) + return vmf_insert_pfn(vma, vmf->address, + sym_to_pfn(vdso_data)); + return VM_FAULT_SIGBUS; +} + static int __setup_additional_pages(enum vdso_abi abi, struct mm_struct *mm, struct linux_binprm *bprm, @@ -150,7 +153,7 @@ static int __setup_additional_pages(enum vdso_abi abi, } ret = _install_special_mapping(mm, vdso_base, PAGE_SIZE, - VM_READ|VM_MAYREAD, + VM_READ|VM_MAYREAD|VM_PFNMAP, vdso_info[abi].dm); if (IS_ERR(ret)) goto up_fail; @@ -209,6 +212,7 @@ static struct vm_special_mapping aarch32_vdso_maps[] = { #ifdef CONFIG_COMPAT_VDSO [AA32_MAP_VVAR] = { .name = "[vvar]", + .fault = vvar_fault, }, [AA32_MAP_VDSO] = { .name = "[vdso]", @@ -376,6 +380,7 @@ enum aarch64_map { static struct vm_special_mapping aarch64_vdso_maps[] __ro_after_init = { [AA64_MAP_VVAR] = { .name = "[vvar]", + .fault = vvar_fault, }, [AA64_MAP_VDSO] = { .name = "[vdso]", -- 2.24.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel