[PATCH 16/18] arm64: Allow "optional" CPU features to be required sometimes

From: James Houghton

Date: Tue Jul 07 2026 - 23:13:10 EST


The HugeTLB vmemmap optimization feature should be optional if HVO is
not in fact in use. Otherwise, on systems where the boot CPUs support
HVO (HW AF) but the late CPUs do not, simply compiling with HVO support
will prevent late-onlining.

It is desirable to always compile in support for HVO without regressing
late-onlining of CPUs on systems where HVO is not in use at run-time.

If HVO is in fact in use at late-online time, HVO must have a way to
prevent such incompatible CPUs from being onlined.

Add the late_cpu_enable() callback to provide this "sometimes required"
functionality.

Signed-off-by: James Houghton <jthoughton@xxxxxxxxxx>
---
arch/arm64/include/asm/cpufeature.h | 8 ++++++++
arch/arm64/kernel/cpufeature.c | 8 ++++++++
2 files changed, 16 insertions(+)

diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index a62c284962cf..d1504804f2be 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -367,6 +367,14 @@ struct arm64_cpu_capabilities {
* routine must check it before taking any action.
*/
void (*cpu_enable)(const struct arm64_cpu_capabilities *cap);
+ /*
+ * In rare cases, capabilities are *sometimes* optional for late CPUs.
+ * This callback allows a capability to prevent onlining of
+ * incompatible CPUs when the capability is in fact required.
+ *
+ * Returns true iff onlining the CPU is permitted.
+ */
+ bool (*late_cpu_enable)(const struct arm64_cpu_capabilities *cap);
union {
struct { /* To be used for erratum handling only */
struct midr_range midr_range;
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index c13433316e80..7e2c134f3b55 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -3684,6 +3684,14 @@ static void verify_local_cpu_caps(u16 scope_mask)
*/
if (!cpu_has_cap && !cpucap_late_cpu_optional(caps))
break;
+
+ /*
+ * Some optional features may in fact be required due
+ * to particular runtime conditions.
+ */
+ if (caps->late_cpu_enable && !caps->late_cpu_enable(caps))
+ break;
+
/*
* We have to issue cpu_enable() irrespective of
* whether the CPU has it or not, as it is enabeld
--
2.55.0.795.g602f6c329a-goog