>From fcb16e1eb494d2ce21792495955d6d3f26c319c9 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Brucker Date: Wed, 12 Jun 2024 09:08:17 +0100 Subject: [PATCH 2/2] squash! arm64: Detect if in a realm and set RIPAS RAM Before issuing an SMC, detect whether SMCCC is available through this conduit. On platforms that do not implement EL3 nor EL2, the SMC instruction is UNDEFINED. SMCCC advises probing the SMCCC availability by first looking for a PSCI node in DT (or in ACPI, but we expect a realm to boot with DT at the moment). Since RMM requires using the SMC conduit for both PSCI and RSI, we rely on the PSCI method property to ensure SMC is available. We could also check that the SMCCC version is at least 1.2 as required by RMM, but no platform requires this extra step at the moment, and we can't use the SMCCC helpers this early in boot. Signed-off-by: Jean-Philippe Brucker --- arch/arm64/kernel/rsi.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c index 898952d135b0..21fc261a1d26 100644 --- a/arch/arm64/kernel/rsi.c +++ b/arch/arm64/kernel/rsi.c @@ -7,6 +7,7 @@ #include #include #include +#include #include @@ -82,6 +83,12 @@ void __init arm64_rsi_setup_memory(void) void __init arm64_rsi_init(void) { + /* + * If PSCI isn't using SMC, RMM isn't present. Don't try to execute an + * SMC as it could be UNDEFINED. + */ + if (!psci_early_test_conduit(SMCCC_CONDUIT_SMC)) + return; if (!rsi_version_matches()) return; if (rsi_get_realm_config(&config)) -- 2.45.2