From: Mark Brown <broonie@kernel.org>
To: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>
Cc: Mark Brown <broonie@kernel.org>, Andrei Vagin <avagin@gmail.com>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 08/11] arm64: vdso: Simplify pagelist allocation
Date: Wed, 1 Jul 2020 21:28:43 +0100 [thread overview]
Message-ID: <20200701202846.54648-9-broonie@kernel.org> (raw)
In-Reply-To: <20200701202846.54648-1-broonie@kernel.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 <broonie@kernel.org>
---
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
next prev parent reply other threads:[~2020-07-01 20:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-01 20:28 [PATCH v2 00/11] arm64: vdso: getcpu() support Mark Brown
2020-07-01 20:28 ` [PATCH v2 01/11] arm64: vdso: Provide a define when building the vDSO Mark Brown
2020-07-01 20:28 ` [PATCH v2 02/11] arm64: vdso: Add per-CPU data Mark Brown
2020-07-01 20:28 ` [PATCH v2 03/11] arm64: vdso: Initialise the per-CPU vDSO data Mark Brown
2020-07-01 20:28 ` [PATCH v2 04/11] arm64: vdso: Add getcpu() implementation Mark Brown
2020-07-01 20:28 ` [PATCH v2 05/11] arm64: vdso: Remove union in declaration of the data store Mark Brown
2020-07-01 20:28 ` [PATCH v2 06/11] arm64: vdso: Document and verify alignment of vDSO text Mark Brown
2020-07-01 20:28 ` [PATCH v2 07/11] arm64: vdso: Rename vdso_pages to vdso_text_pages Mark Brown
2020-07-01 20:28 ` Mark Brown [this message]
2020-07-01 20:28 ` [PATCH v2 09/11] arm64: vdso: Parameterise vDSO data length assumptions in code Mark Brown
2020-07-01 20:28 ` [PATCH v2 10/11] arm64: vdso: Support multiple pages of vDSO data Mark Brown
2020-07-01 20:28 ` [PATCH v2 11/11] selftests: vdso: Support arm64 in getcpu() test Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200701202846.54648-9-broonie@kernel.org \
--to=broonie@kernel.org \
--cc=avagin@gmail.com \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--cc=vincenzo.frascino@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).