[RFC PATCH v2 28/43] arm64: cpufeature: Add capabilities for the page size in use
Eric Curtin
ericcurtin17 at gmail.com
Mon Nov 30 17:52:00 PST 2026
From: Ryan Roberts <ryan.roberts at arm.com>
Add one boot CPU capability per page size, ARM64_USE_PAGE_SIZE_4K,
ARM64_USE_PAGE_SIZE_16K and ARM64_USE_PAGE_SIZE_64K. Exactly one of them
is set, according to PAGE_SIZE, by the new use_page_size() match
function. This lets the alternatives framework patch code, such as
assembly that needs the page shift as an immediate, according to the
page size selected at boot.
The capability descriptions also make the page size in use visible in
the kernel log during boot.
Signed-off-by: Ryan Roberts <ryan.roberts at arm.com>
Signed-off-by: Eric Curtin <eric.curtin at docker.com>
(cherry picked from commit fc11b748a3ad8b591f1ae32c8b6f9f607865d06c)
---
arch/arm64/kernel/cpufeature.c | 25 +++++++++++++++++++++++++
arch/arm64/tools/cpucaps | 3 +++
2 files changed, 28 insertions(+)
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 0090ec390cf8..553d30eb1e1a 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1780,6 +1780,13 @@ static bool has_nv1(const struct arm64_cpu_capabilities *entry, int scope)
is_midr_in_range_list(nv1_ni_list)));
}
+static bool use_page_size(const struct arm64_cpu_capabilities *entry, int scope)
+{
+ return (entry->capability == ARM64_USE_PAGE_SIZE_4K && PAGE_SIZE == SZ_4K) ||
+ (entry->capability == ARM64_USE_PAGE_SIZE_16K && PAGE_SIZE == SZ_16K) ||
+ (entry->capability == ARM64_USE_PAGE_SIZE_64K && PAGE_SIZE == SZ_64K);
+}
+
static bool has_lpa2_at_stage1(u64 mmfr0)
{
unsigned int tgran;
@@ -3112,6 +3119,24 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
ARM64_CPUID_FIELDS(ID_AA64ISAR3_EL1, LSUI, IMP)
},
#endif
+ {
+ .desc = "4K page size",
+ .capability = ARM64_USE_PAGE_SIZE_4K,
+ .type = ARM64_CPUCAP_BOOT_CPU_FEATURE,
+ .matches = use_page_size,
+ },
+ {
+ .desc = "16K page size",
+ .capability = ARM64_USE_PAGE_SIZE_16K,
+ .type = ARM64_CPUCAP_BOOT_CPU_FEATURE,
+ .matches = use_page_size,
+ },
+ {
+ .desc = "64K page size",
+ .capability = ARM64_USE_PAGE_SIZE_64K,
+ .type = ARM64_CPUCAP_BOOT_CPU_FEATURE,
+ .matches = use_page_size,
+ },
{},
};
diff --git a/arch/arm64/tools/cpucaps b/arch/arm64/tools/cpucaps
index a0a0ee33fd09..a3a9f297ae75 100644
--- a/arch/arm64/tools/cpucaps
+++ b/arch/arm64/tools/cpucaps
@@ -93,6 +93,9 @@ SPECTRE_BHB
SSBS
SVE
UNMAP_KERNEL_AT_EL0
+USE_PAGE_SIZE_4K
+USE_PAGE_SIZE_16K
+USE_PAGE_SIZE_64K
WORKAROUND_834220
WORKAROUND_843419
WORKAROUND_845719
More information about the linux-arm-kernel
mailing list