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=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 3A006C433DF for ; Wed, 1 Jul 2020 20:31:00 +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 0D61520853 for ; Wed, 1 Jul 2020 20:31:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="aVs5UNbV"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="UsI77RDd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D61520853 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=5XkbKMp091CTzPPcft7PniPHWLPUBUqCcmDIcKpNjbM=; b=aVs5UNbVm5wMxHhfMp01x6ubT VqzogsCY4uH8tys9Fl9/RkNLnUIaeEEuQelzPECekuzoapPaXSkaTFPvMXu2NV5Iq1YayhQXqAlgS /FpesabRCnr7ed0bOz83inZdAQTN+eX7Jgu+UvNYynKj+ZE+rFR3B+wtTDFJ5B8bJLdWG2rO+VgG5 oTtoZWOiUGA6PxP0GBzO4jKrgHPUgm1QFinQR6/nstQt9UMdEX8IcWWreRQX2un7kxuoElN1vSQnt fipACWkWndIjExXbhWyZpYXVETOFjxtXt5NS+TsdrGHsqxyEHeZKyKh1hWix/rLZ3wMgIr0CDa7KA WXmyLat8Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqjMW-0004g7-DE; Wed, 01 Jul 2020 20:29:44 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqjMM-0004aw-4F for linux-arm-kernel@lists.infradead.org; Wed, 01 Jul 2020 20:29:35 +0000 Received: from localhost (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0306E2071A; Wed, 1 Jul 2020 20:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593635373; bh=bZBSyAsnYVoR8Pv3UFnf5V/SCQ7AIDTvhkcTUogyk2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UsI77RDdAw+4v07sykLjGrBX6R0OY8e5azaN/x8HsmMWe/z9g45Ti+G2W3Mg1vWsF JvcyOT/VeNydOhrJAMPoT9ATV+d4xADEH5jx+rBNUWQd2ZqcdcK/xjUwmeujw3Retc tfuzOPGZ9w+FdOHXhPQJ5OuVygC3R3O5hLN2XpHI= From: Mark Brown To: Catalin Marinas , Will Deacon , Marc Zyngier Subject: [PATCH v2 09/11] arm64: vdso: Parameterise vDSO data length assumptions in code Date: Wed, 1 Jul 2020 21:28:44 +0100 Message-Id: <20200701202846.54648-10-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200701202846.54648-1-broonie@kernel.org> References: <20200701202846.54648-1-broonie@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200701_162934_328795_DEBFBF5E X-CRM114-Status: GOOD ( 14.81 ) 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: Mark Brown , Andrei Vagin , Vincenzo Frascino , linux-arm-kernel@lists.infradead.org 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 In preparation for adding per-CPU data for the vDSO factor out the assumptions about the vDSO having a single data page so that we use a function vdso_data_size() to determine the actual length and a vdso_data_pages to determine the number of pages mapped for data. The actual data size and runtime behaviour are currently unaffected. Signed-off-by: Mark Brown --- arch/arm64/include/asm/vdso.h | 7 +++++++ arch/arm64/kernel/vdso.c | 18 ++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/vdso.h b/arch/arm64/include/asm/vdso.h index 07468428fd29..c7edf7a7491f 100644 --- a/arch/arm64/include/asm/vdso.h +++ b/arch/arm64/include/asm/vdso.h @@ -12,6 +12,13 @@ */ #define VDSO_LBASE 0x0 +/* + * Hard code magic numbers since we need these in vdso.lds.S, there + * are BUILD_BUG_ON() checks in vdso.c to make sure these are correct. + */ +#define VDSO_BASE_DATA_SIZE 240 +#define VDSO_CS_BASES 2 + #ifndef __ASSEMBLY__ #include diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index f78349faa6c4..e1146f424e6f 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -48,6 +48,7 @@ struct vdso_abi_info { const char *vdso_code_start; const char *vdso_code_end; unsigned long vdso_text_pages; + unsigned long vdso_data_pages; /* Data Mapping */ struct vm_special_mapping *dm; /* Code Mapping */ @@ -110,6 +111,8 @@ static int __vdso_init(enum vdso_abi abi) return -EINVAL; } + BUILD_BUG_ON(sizeof(struct vdso_data) != VDSO_BASE_DATA_SIZE); + /* * We ensure that the vDSO text is page aligned and an exact * number of pages in vdso.S so don't need to round here. @@ -123,9 +126,11 @@ static int __vdso_init(enum vdso_abi abi) vdso_info[abi].vdso_code_end - vdso_info[abi].vdso_code_start) >> PAGE_SHIFT; + vdso_info[abi].vdso_data_pages = VDSO_DATA_PAGES; vdso_info[abi].dm->pages = - vdso_get_pages(sym_to_pfn(vdso_data), 1); + vdso_get_pages(sym_to_pfn(vdso_data), + vdso_info[abi].vdso_data_pages); vdso_info[abi].cm->pages = vdso_get_pages(sym_to_pfn(vdso_info[abi].vdso_code_start), vdso_info[abi].vdso_text_pages); @@ -141,13 +146,14 @@ static int __setup_additional_pages(enum vdso_abi abi, struct linux_binprm *bprm, int uses_interp) { - unsigned long vdso_base, vdso_text_len, vdso_mapping_len; + unsigned long vdso_base, vdso_mapping_len; + unsigned long vdso_text_len, vdso_data_len; unsigned long gp_flags = 0; void *ret; vdso_text_len = vdso_info[abi].vdso_text_pages << PAGE_SHIFT; - /* Be sure to map the data page */ - vdso_mapping_len = vdso_text_len + PAGE_SIZE; + vdso_data_len = vdso_info[abi].vdso_data_pages << PAGE_SHIFT; + vdso_mapping_len = vdso_text_len + vdso_data_len; vdso_base = get_unmapped_area(NULL, 0, vdso_mapping_len, 0, 0); if (IS_ERR_VALUE(vdso_base)) { @@ -155,7 +161,7 @@ static int __setup_additional_pages(enum vdso_abi abi, goto up_fail; } - ret = _install_special_mapping(mm, vdso_base, PAGE_SIZE, + ret = _install_special_mapping(mm, vdso_base, vdso_data_len, VM_READ|VM_MAYREAD, vdso_info[abi].dm); if (IS_ERR(ret)) @@ -164,7 +170,7 @@ static int __setup_additional_pages(enum vdso_abi abi, if (IS_ENABLED(CONFIG_ARM64_BTI_KERNEL) && system_supports_bti()) gp_flags = VM_ARM64_BTI; - vdso_base += PAGE_SIZE; + vdso_base += vdso_data_len; mm->context.vdso = (void *)vdso_base; ret = _install_special_mapping(mm, vdso_base, vdso_text_len, VM_READ|VM_EXEC|gp_flags| -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel