[RFC PATCH v2 4/4] arm64: realm: Move RSI detection earlier
Suzuki K Poulose
suzuki.poulose at arm.com
Tue May 5 08:57:42 PDT 2026
As discussed in [0], Realm world detection happens too late for making the
decision for the Linear map granularity for Arm64. If the boot CPU doesn't support
BBML2_NOABORT, it is difficult to break the mapping to PTE level. To solve this
try probing the Realm world earlier, now that we probe the PSCI/SMCCC earlier.
Like the PSCI probe, if we fall back to the later point if the SMCCC probe
wasn't successful. We should probably add a WARNING/panic the system if the
BBML2_NOABORT is not supported on the boot CPU and linear map was created
with block mappings. This may case avoided by using rodata=full.
[0] https://lore.kernel.org/all/20260330161705.3349825-2-ryan.roberts@arm.com/
Signed-off-by: Suzuki K Poulose <suzuki.poulose at arm.com>
---
arch/arm64/include/asm/rsi.h | 1 +
arch/arm64/kernel/rsi.c | 23 ++++++++++++++++++++++-
arch/arm64/kernel/setup.c | 3 ++-
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/include/asm/rsi.h b/arch/arm64/include/asm/rsi.h
index 88b50d660e85..4456bf0a1f23 100644
--- a/arch/arm64/include/asm/rsi.h
+++ b/arch/arm64/include/asm/rsi.h
@@ -14,6 +14,7 @@
DECLARE_STATIC_KEY_FALSE(rsi_present);
+void __init arm64_early_rsi_init(void);
void __init arm64_rsi_init(void);
bool arm64_rsi_is_protected(phys_addr_t base, size_t size);
diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c
index 92160f2e57ff..f0fd0922609d 100644
--- a/arch/arm64/kernel/rsi.c
+++ b/arch/arm64/kernel/rsi.c
@@ -139,10 +139,14 @@ static int realm_ioremap_hook(phys_addr_t phys, size_t size, pgprot_t *prot)
return 0;
}
-void __init arm64_rsi_init(void)
+static bool rsi_probed = 0;
+
+static void __init rsi_probe(void)
{
if (arm_smccc_1_1_get_conduit() != SMCCC_CONDUIT_SMC)
return;
+
+ rsi_probed = true;
if (!rsi_version_matches())
return;
if (WARN_ON(rsi_get_realm_config(lm_alias(&config))))
@@ -160,6 +164,23 @@ void __init arm64_rsi_init(void)
static_branch_enable(&rsi_present);
}
+void __init arm64_early_rsi_init(void)
+{
+ rsi_probe();
+}
+
+void __init arm64_rsi_init(void)
+{
+ if (rsi_probed)
+ return;
+
+ rsi_probe();
+ /*
+ * TODO: Warn if we don't have BBML2_NOABORT and page mapping is
+ * not used.
+ */
+}
+
static struct platform_device rsi_dev = {
.name = RSI_PDEV_NAME,
.id = PLATFORM_DEVID_NONE
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index af35a0f3b7d0..0b530a090150 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -350,7 +350,8 @@ static void __init early_psci_init(void)
return;
}
- psci_early_init_conduit(conduit);
+ if (!psci_early_init_conduit(conduit))
+ arm64_early_rsi_init();
}
void __init __no_sanitize_address setup_arch(char **cmdline_p)
--
2.43.0
More information about the linux-arm-kernel
mailing list