[PATCH v2 06/11] arm64: vdso: Document and verify alignment of vDSO text

Mark Brown broonie at kernel.org
Wed Jul 1 16:28:41 EDT 2020


We do no rounding when working out the number of vDSO text pages because
we ensure in vdso.S that the vDSO text is an exact number of pages long.
This is not immediately apparent when looking at the code that does the
vDSO mapping in vdso.c so add a comment explaining what's going on and
check that this assumption is true.

Ideally we'd have a BUILD_BUG_ON() but since the start and end come from
another compilation unit it needs to be a runtime check, add one which
prints a warning and errors out similarly to the existing check for the
vDSO not being an ELF object.

Signed-off-by: Mark Brown <broonie at kernel.org>
---
 arch/arm64/kernel/vdso.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index b05e4d5880af..95e69df42141 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -99,6 +99,15 @@ static int __vdso_init(enum vdso_abi abi)
 		return -EINVAL;
 	}
 
+	/*
+	 * 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.
+	 */
+	if (!PAGE_ALIGNED(vdso_info[abi].vdso_code_start) ||
+	    !PAGE_ALIGNED(vdso_info[abi].vdso_code_end)) {
+		pr_err("vDSO is not page aligned\n");
+		return -EINVAL;
+	}
 	vdso_info[abi].vdso_pages = (
 			vdso_info[abi].vdso_code_end -
 			vdso_info[abi].vdso_code_start) >>
-- 
2.20.1




More information about the linux-arm-kernel mailing list