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 F1F6DC433E0 for ; Wed, 1 Jul 2020 20:31:02 +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 BEED52085B for ; Wed, 1 Jul 2020 20:31:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="degjgvX9"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="sOeLrkO2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BEED52085B 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=EAJGVKfRwi8ACcI1MDb5wTUnIuDL8xznE3cbjRgOoSM=; b=degjgvX9kby98EiJhCh9EcHyp GBJIDT2UX/f+MdSznkED9hkxUREpn/Fem0I/aU6Lrsu2/JnFJfrinwpdlR+4uin8D8KX4mBUs7nmS dKxbUMvo1a3E5tPWn96fs1FOQqPYvbzE4jC/ZfvPT5bQwgM9QZ2+GJsZyXvJigUXTiqYhvl5yae2S 8VelX+CzsXa2BE7PfZbv3Gwr32j3AvL+UccQ5tfEx//pw2YU0O2nMU+r1puLrEaV+OUE4an34rmJf bj4dtirCz2ciDDD3jT15w7BtnVnrJGPL49dyqOwfBt/aV9GIS494nLXLivDKAEQ9v814AliRSB3VS 3v6Dav9/w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqjMT-0004ex-Tj; Wed, 01 Jul 2020 20:29:41 +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 1jqjMJ-0004Zd-Ic for linux-arm-kernel@lists.infradead.org; Wed, 01 Jul 2020 20:29:32 +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 7DF9A208A7; Wed, 1 Jul 2020 20:29:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593635371; bh=H1CSoyV40D3K9xMkyiIQT7HPucfWWXDsIFdTWVa36K8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sOeLrkO2dQfCX4jg4IX30rLbxWzK0BL1wCT3yZilAAyrB+9OryGDR018PTPcEkYCe UsqbPYYn7SnWZn6CDQdLWVIdxXDrtYrN3y8A99ZW8ShHYpKa2FS+BQWM5nmz0+rwez rxpT+Q1oHMFg78PU8OcdNVUmrE2OTa7ROGYnd/Ms= From: Mark Brown To: Catalin Marinas , Will Deacon , Marc Zyngier Subject: [PATCH v2 08/11] arm64: vdso: Simplify pagelist allocation Date: Wed, 1 Jul 2020 21:28:43 +0100 Message-Id: <20200701202846.54648-9-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_162931_740068_5708091F X-CRM114-Status: GOOD ( 16.03 ) 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 Currently we allocate a single array for the struct page * for the vDSO and then do the lookup for code and data in slightly different ways. Make this more regular by factoring out the array allocation and struct page * lookup into a function and using it for both. We don't currently rely on everything being in one array so there should be no functional change. Signed-off-by: Mark Brown --- arch/arm64/kernel/vdso.c | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index 032249f70460..f78349faa6c4 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -88,12 +88,23 @@ static int __vdso_remap(enum vdso_abi abi, return 0; } -static int __vdso_init(enum vdso_abi abi) +static struct page **vdso_get_pages(unsigned long pfn, size_t pages) { + struct page **pagelist; int i; - struct page **vdso_pagelist; - unsigned long pfn; + pagelist = kcalloc(pages, sizeof(struct page *), GFP_KERNEL); + if (!pagelist) + return NULL; + + for (i = 0; i < pages; i++) + pagelist[i] = pfn_to_page(pfn + i); + + return pagelist; +} + +static int __vdso_init(enum vdso_abi abi) +{ if (memcmp(vdso_info[abi].vdso_code_start, "\177ELF", 4)) { pr_err("vDSO is not a valid ELF object!\n"); return -EINVAL; @@ -113,25 +124,14 @@ 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_text_pages + 1, - 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)); - + vdso_info[abi].dm->pages = + vdso_get_pages(sym_to_pfn(vdso_data), 1); + vdso_info[abi].cm->pages = + vdso_get_pages(sym_to_pfn(vdso_info[abi].vdso_code_start), + vdso_info[abi].vdso_text_pages); - /* Grab the vDSO code pages. */ - pfn = sym_to_pfn(vdso_info[abi].vdso_code_start); - - for (i = 0; i < vdso_info[abi].vdso_text_pages; i++) - vdso_pagelist[i + 1] = pfn_to_page(pfn + i); - - vdso_info[abi].dm->pages = &vdso_pagelist[0]; - vdso_info[abi].cm->pages = &vdso_pagelist[1]; + if (!vdso_info[abi].cm->pages || !vdso_info[abi].dm->pages) + return -ENOMEM; return 0; } -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel