Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2258295ybt; Tue, 16 Jun 2020 00:58:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyY7bM8kHdA2R3pP55ZuwqWKeyzFK+NuCTGIsJHS7h3wyMsoNsc7RFNFAKWJOgLWrt3X3Z3 X-Received: by 2002:a50:e1c5:: with SMTP id m5mr1438480edl.47.1592294291580; Tue, 16 Jun 2020 00:58:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592294291; cv=none; d=google.com; s=arc-20160816; b=dXOLCs6legeACLY9cUDfSLCLNC1HiY7oyoJ+5aB3pcaEBONp6iHpYCsAMgGymu2RWR yfG3YzhhDetbnNO5NS7572AZcfvOvWG313AHfDAWxz6mQcN9siP9AX/hYvloEqwNU4Lw rjR6vv9liwZc8asus8T8iy+iBnxrBSQDD+LhahV1Gm4QHa/QB/c024QpxdiCE89Iv2e2 0lagwigjUzekK6ioKIipR55I0zGJhoy0ds3g/LzSme6tvqPYk/kY33fX2qJD17fXBLUj fQujCUhVuheu2E6qLiiaIGflRQB8trLs5Hvez7EOna86fSi6EYYqeuusnyk6LznLg3ff zb5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=3w3acXY0ruvQ2cOAk5Y6lKlS5LzTqXqZJuB6w0EA294=; b=rymgLfw7RBU/cfeVBC/5ePkEryLu90KzGgZNkkBdv6WlA9R1LvyGnZpv//QPlg/NQb we9EhJcCplQHdhIGPeCmxQzJvzuiJaYbEjSHePWgB5lkhXQ0t/ir/kvk8P4iGrd3oPJA jpguxCuAJ9mk5hOxIW4y6ZXc+O5hmnu3oiuvoF4LvnNajP0SzEGOrfZ4b3IdrqlpSjjm cDCYuObLTR1skScLb+xH9GsvUWP6NZJxj0jBFtJnliQJb6Vv2aYauxswW84cRGjyShGh xgj7KdshMZCexNxeUT7eqXC6tRbPYHpGExp1kN+liMklWNN5Yz2vYl9XM+3peZ90KfCZ GDLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Cp8t/bjO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b23si9661034edx.118.2020.06.16.00.57.47; Tue, 16 Jun 2020 00:58:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Cp8t/bjO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726626AbgFPHz5 (ORCPT + 99 others); Tue, 16 Jun 2020 03:55:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725896AbgFPHz4 (ORCPT ); Tue, 16 Jun 2020 03:55:56 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A9A8C03E96A for ; Tue, 16 Jun 2020 00:55:56 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id u8so1062459pje.4 for ; Tue, 16 Jun 2020 00:55:56 -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=3w3acXY0ruvQ2cOAk5Y6lKlS5LzTqXqZJuB6w0EA294=; b=Cp8t/bjOY0qFMLYTzt16FoouVp9eINWmU8mmUpHX+AsFrDKIXkcT19z0suqBLghibO OsWPTbNQ78wf/cMk9oUek30lb6kngbCTL91Ip4B4OBjsGHxi5xA/ijlrqrQlNLoGn/bn l/7vyPUklqJG1Baun2pVxMHTasoW42ICl3Es6lVrZb83u6aebgtl+kJzIuZw8wkSuD5y eWg48lc4rfg+C2iE2LQQqoBLqeCS++0+HVWVXWygJpkK1vDfoep1tzRrEdYp2cVb/jvQ JC/cob986QCwZA/FpwkUZqZkbS85NacBJV0l0OpFKfn0vQWwu3XC3bjPcGWjDJb+aU5E KZMw== 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=3w3acXY0ruvQ2cOAk5Y6lKlS5LzTqXqZJuB6w0EA294=; b=awoV5ovljTrTIw/eKb059iZqhWStC2E81kPhGILyqTct543fDw/rNo3r9si3LUWKnz TTGzPMCVWm6o48fx+9uhm53VUgi5ZdVt66pbzf4UfpVEEST/+WY4EUbn0KLJ0DC71tS8 QKMMD3cqCf9LXhZF6ooLfVU8aSqNZZH6jnjFkPGY5varfTaAIBtZhqayXTy4UJfY9OPf 7o9ne+Yy69mhC8LbWfaxKhzAwBDESzkvrVNkBadUzQ7/sNBb7VL0ga0B4CsarMWj8kfZ Lo3yIx6XKHNpQzEXLHSYTFKyuq2Ylz4pYM4+nu2U7EqPN9oGYeNJH03wk5Hre8mC+UAC ytog== X-Gm-Message-State: AOAM530zmowY6krtW+uzjwvhS2YTLSjAA3CURX2Oigcr1afI0vvpvD5F 1ySw8hZ0Oz2ybXqMiTC9low= X-Received: by 2002:a17:90a:356a:: with SMTP id q97mr1861201pjb.110.1592294155840; Tue, 16 Jun 2020 00:55:55 -0700 (PDT) Received: from laptop.hsd1.wa.comcast.net ([2601:600:817f:a132:df3e:521d:99d5:710d]) by smtp.gmail.com with ESMTPSA id g6sm16168984pfb.164.2020.06.16.00.55.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 00:55:55 -0700 (PDT) From: Andrei Vagin To: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon Cc: linux-kernel@vger.kernel.org, Vincenzo Frascino , Mark Rutland , Thomas Gleixner , Dmitry Safonov , Andrei Vagin Subject: [PATCH 1/6] arm64/vdso: use the fault callback to map vvar pages Date: Tue, 16 Jun 2020 00:55:40 -0700 Message-Id: <20200616075545.312684-2-avagin@gmail.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200616075545.312684-1-avagin@gmail.com> References: <20200616075545.312684-1-avagin@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is required to support time namespaces where a time namespace data page is different for each namespace. Reviewed-by: Vincenzo Frascino Reviewed-by: Dmitry Safonov Signed-off-by: Andrei Vagin --- arch/arm64/kernel/vdso.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index 4e016574bd91..b0aec4e8c9b4 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -108,28 +108,32 @@ static int __vdso_init(enum vdso_abi abi) 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 +154,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 +213,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 +381,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