[Buildroot] [PATCH 1/1] arch/arm: Choose page size for AArch64

Łukasz Stelmach l.stelmach at samsung.com
Fri Dec 3 20:25:59 UTC 2021


MMUs on AArch64 support three different page sizes: 4 kB, 16 kB,
and 64 kB. It is OS kernel's task to choose the configuration during
boot. Linux kernel can be compiled to support different page size.
To run on a system with pages larger than 4 kB userland binaries need
to be properly aligned during the linking process. However, binaries
prepared for systems with larger pages can run on systems with smaller
pages.

Signed-off-by: Łukasz Stelmach <l.stelmach at samsung.com>
---
 arch/Config.in.arm | 24 ++++++++++++++++++++++++
 arch/arch.mk.arm   | 12 ++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 arch/arch.mk.arm

diff --git a/arch/Config.in.arm b/arch/Config.in.arm
index 4c0910e4f8..bc6452878d 100644
--- a/arch/Config.in.arm
+++ b/arch/Config.in.arm
@@ -930,5 +930,29 @@ config BR2_READELF_ARCH_NAME
 	default "ARM"		if BR2_arm || BR2_armeb
 	default "AArch64"	if BR2_aarch64 || BR2_aarch64_be
 
+choice
+	prompt "Aarch64 MMU Page Size"
+	default BR2_ARM_PAGE_SIZE_4K
+	depends on BR2_aarch64 || BR2_aarch64_be
+	help
+	  Choose MMU page size
+
+config BR2_ARM_PAGE_SIZE_4K
+	bool "4KB"
+
+config BR2_ARM_PAGE_SIZE_16K
+	bool "16KB"
+
+config BR2_ARM_PAGE_SIZE_64K
+	bool "64KB"
+
+endchoice
+
+config BR2_ARM_PAGE_SIZE
+	string
+	default "4K" if BR2_ARM_PAGE_SIZE_4K
+	default "16K" if BR2_ARM_PAGE_SIZE_16K
+	default "64K" if BR2_ARM_PAGE_SIZE_64K
+
 # vim: ft=kconfig
 # -*- mode:kconfig; -*-
diff --git a/arch/arch.mk.arm b/arch/arch.mk.arm
new file mode 100644
index 0000000000..ef65c60f6c
--- /dev/null
+++ b/arch/arch.mk.arm
@@ -0,0 +1,12 @@
+ifeq ($(filter y, $(BR2_aarch64) $(BR2_aarch64_be)), y)
+
+# Explicitly set LD's "max-page-size" instead of relying on some defaults
+ifeq ($(BR2_ARM_PAGE_SIZE_4K),y)
+ARCH_TOOLCHAIN_WRAPPER_OPTS += -Wl,-z,max-page-size=4096
+else ifeq ($(BR2_ARM_PAGE_SIZE_16K),y)
+ARCH_TOOLCHAIN_WRAPPER_OPTS += -Wl,-z,max-page-size=32768
+else ifeq ($(BR2_ARM_PAGE_SIZE_64K),y)
+ARCH_TOOLCHAIN_WRAPPER_OPTS += -Wl,-z,max-page-size=65536
+endif
+
+endif
-- 
2.30.2




More information about the buildroot mailing list