linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
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 10/11] arm64: vdso: Support multiple pages of vDSO data
Date: Wed,  1 Jul 2020 21:28:45 +0100	[thread overview]
Message-ID: <20200701202846.54648-11-broonie@kernel.org> (raw)
In-Reply-To: <20200701202846.54648-1-broonie@kernel.org>

In order to provide per-CPU data for systems with larger numbers of CPUs
we need multiple data pages for the vDSO, exactly how many will depend on
the page size and the maximum number of CPUs the kernel is configured to
support.

Since the vDSO references the data via a symbol defined in the linker
script we need to be able to reference the sizes of structures defined
in C which appears not to be something we have sensible support for.
Handle this by defining magic numbers and using BUILD_BUG_ON() which
checks that the numbers are accurate, this is rather distasteful but
works. Currently the patch duplicates CS_BASES, with the hard coding of
struct sizes it felt like more trouble than it was worth to move it into
an assembler clean header.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 arch/arm64/include/asm/vdso.h     | 4 ++++
 arch/arm64/kernel/vdso.c          | 2 ++
 arch/arm64/kernel/vdso/vdso.lds.S | 2 +-
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/vdso.h b/arch/arm64/include/asm/vdso.h
index c7edf7a7491f..21e35d79022a 100644
--- a/arch/arm64/include/asm/vdso.h
+++ b/arch/arm64/include/asm/vdso.h
@@ -18,6 +18,10 @@
  */
 #define VDSO_BASE_DATA_SIZE 240
 #define VDSO_CS_BASES       2
+#define VDSO_PER_CPU_SIZE   8
+#define VDSO_DATA_SIZE      ((VDSO_PER_CPU_SIZE * CONFIG_NR_CPUS)	\
+			     + (VDSO_BASE_DATA_SIZE * VDSO_CS_BASES))
+#define VDSO_DATA_PAGES     ((VDSO_DATA_SIZE / PAGE_SIZE) + 1)
 
 #ifndef __ASSEMBLY__
 
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index e1146f424e6f..b0899591d91e 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -112,6 +112,8 @@ static int __vdso_init(enum vdso_abi abi)
 	}
 
 	BUILD_BUG_ON(sizeof(struct vdso_data) != VDSO_BASE_DATA_SIZE);
+	BUILD_BUG_ON(CS_BASES != VDSO_CS_BASES);
+	BUILD_BUG_ON(sizeof(struct vdso_cpu_data) != VDSO_PER_CPU_SIZE);
 
 	/*
 	 * We ensure that the vDSO text is page aligned and an exact
diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S
index c2fd94f14b94..7ee43b149bf9 100644
--- a/arch/arm64/kernel/vdso/vdso.lds.S
+++ b/arch/arm64/kernel/vdso/vdso.lds.S
@@ -17,7 +17,7 @@ OUTPUT_ARCH(aarch64)
 
 SECTIONS
 {
-	PROVIDE(_vdso_data = . - PAGE_SIZE);
+	PROVIDE(_vdso_data = . - (VDSO_DATA_PAGES * PAGE_SIZE));
 	. = VDSO_LBASE + SIZEOF_HEADERS;
 
 	.hash		: { *(.hash) }			:text
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  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 ` [PATCH v2 08/11] arm64: vdso: Simplify pagelist allocation Mark Brown
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 ` Mark Brown [this message]
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-11-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).