[RFC PATCH v2 18/43] arm64: Add arm64.pagesize= command line override
Eric Curtin
ericcurtin17 at gmail.com
Mon Nov 30 17:51:50 PST 2026
From: Ryan Roberts <ryan.roberts at arm.com>
Boot-time page size selection needs a way for the user to request a
page size. Accept "arm64.pagesize=4k", "arm64.pagesize=16k" or
"arm64.pagesize=64k", which set a new pageshift field in the
software feature override register. The page shift is stored in a 4 bit
field in compressed form, as (shift - 10) / 2, and
arm64_pageshift_cmdline() converts it back.
The override is only honoured when early_page_shift_supported() accepts
the requested size, that is when the hardware supports it and it lies
within the compile-time [PAGE_SIZE_MIN, PAGE_SIZE_MAX] range. As that
range is a single size for a compile-time page size build, the option
is ignored there.
Signed-off-by: Ryan Roberts <ryan.roberts at arm.com>
Signed-off-by: Eric Curtin <eric.curtin at docker.com>
(cherry picked from commit ca43672932d6d458c531e2b750d1e63da248fd35)
---
arch/arm64/include/asm/cpufeature.h | 11 +++++++++++
arch/arm64/kernel/pi/idreg-override.c | 13 +++++++++++++
2 files changed, 24 insertions(+)
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 7d7b8eb7f72f..405291491866 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -18,6 +18,7 @@
#define ARM64_SW_FEATURE_OVERRIDE_NOKASLR 0
#define ARM64_SW_FEATURE_OVERRIDE_HVHE 4
#define ARM64_SW_FEATURE_OVERRIDE_RODATA_OFF 8
+#define ARM64_SW_FEATURE_OVERRIDE_PAGESHIFT 12
#ifndef __ASSEMBLER__
@@ -1050,6 +1051,16 @@ static inline bool arm64_test_sw_feature_override(int feat)
&arm64_sw_feature_override);
}
+static inline int arm64_pageshift_cmdline(void)
+{
+ int val;
+
+ val = arm64_apply_feature_override(0,
+ ARM64_SW_FEATURE_OVERRIDE_PAGESHIFT,
+ 4, &arm64_sw_feature_override);
+ return val ? val * 2 + 10 : 0;
+}
+
static inline bool kaslr_disabled_cmdline(void)
{
return arm64_test_sw_feature_override(ARM64_SW_FEATURE_OVERRIDE_NOKASLR);
diff --git a/arch/arm64/kernel/pi/idreg-override.c b/arch/arm64/kernel/pi/idreg-override.c
index 2f132b44ef27..f2641106e164 100644
--- a/arch/arm64/kernel/pi/idreg-override.c
+++ b/arch/arm64/kernel/pi/idreg-override.c
@@ -216,6 +216,15 @@ static bool __init hvhe_filter(u64 val)
ID_AA64MMFR1_EL1_VH_SHIFT));
}
+static bool __init pageshift_filter(u64 val)
+{
+ /* pageshift is stored compressed in 4 bit field. */
+ if (val)
+ val = val * 2 + 10;
+
+ return early_page_shift_supported(val);
+}
+
static const struct ftr_set_desc sw_features __prel64_initconst = {
.name = "arm64_sw",
.override = &arm64_sw_feature_override,
@@ -223,6 +232,7 @@ static const struct ftr_set_desc sw_features __prel64_initconst = {
FIELD("nokaslr", ARM64_SW_FEATURE_OVERRIDE_NOKASLR, NULL),
FIELD("hvhe", ARM64_SW_FEATURE_OVERRIDE_HVHE, hvhe_filter),
FIELD("rodataoff", ARM64_SW_FEATURE_OVERRIDE_RODATA_OFF, NULL),
+ FIELD("pageshift", ARM64_SW_FEATURE_OVERRIDE_PAGESHIFT, pageshift_filter),
{}
},
};
@@ -265,6 +275,9 @@ static const struct {
{ "arm64.nolva", "id_aa64mmfr2.varange=0" },
{ "arm64.no32bit_el0", "id_aa64pfr0.el0=1" },
{ "arm64.nompam", "id_aa64pfr0.mpam=0 id_aa64pfr1.mpam_frac=0" },
+ { "arm64.pagesize=4k", "arm64_sw.pageshift=1" },
+ { "arm64.pagesize=16k", "arm64_sw.pageshift=2" },
+ { "arm64.pagesize=64k", "arm64_sw.pageshift=3" },
};
static int __init parse_hexdigit(const char *p, u64 *v)
More information about the linux-arm-kernel
mailing list