From ea85010a633c4c9f015e4d6fd9816fd26d4006f1 Mon Sep 17 00:00:00 2001 From: Ivan Velickovic Date: Fri, 27 Mar 2026 15:15:22 +1100 Subject: [PATCH] loader: handle non-PSCI ARM platforms better This makes things slightly better, main thing is that we make sure we don't try boot secondary CPUs via PSCI if it's unavailable. Signed-off-by: Ivan Velickovic --- loader/src/aarch64/cpus.c | 5 ++++- loader/src/aarch64/init.c | 4 ++-- loader/src/cpus.h | 5 +++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/loader/src/aarch64/cpus.c b/loader/src/aarch64/cpus.c index bf3d81094..130000248 100644 --- a/loader/src/aarch64/cpus.c +++ b/loader/src/aarch64/cpus.c @@ -189,7 +189,7 @@ int plat_start_cpu(int logical_cpu) while (__atomic_load_n(&arm_spin_table_secondary_cpu_data, __ATOMIC_ACQUIRE) != 0); arm_spin_table_cpu_start(logical_cpu, (uint64_t)sp); return 0; -#else +#elif !defined(ARM_PSCI_UNAVAILABLE) uint64_t ret = arm_smc64_call( PSCI_FUNCTION_CPU_ON, /* target_cpu */ psci_target_cpus[logical_cpu], @@ -204,5 +204,8 @@ int plat_start_cpu(int logical_cpu) } return ret; +#else + LDR_PRINT("ERROR", 0, "unknown CPU start method for this platform"); + return -1; #endif } diff --git a/loader/src/aarch64/init.c b/loader/src/aarch64/init.c index 7eafef432..2d8f2e0cd 100644 --- a/loader/src/aarch64/init.c +++ b/loader/src/aarch64/init.c @@ -8,6 +8,7 @@ #include "../arch.h" #include "../loader.h" #include "../uart.h" +#include "../cpus.h" #include "el.h" #include "smc.h" @@ -105,8 +106,7 @@ void arch_init(void) fail(); } - // TODO: handle non-PSCI platforms better, see https://github.com/seL4/microkit/issues/401. -#if !defined(CONFIG_PLAT_BCM2711) && !defined(BOARD_kria_k26) +#if !defined(ARM_PSCI_UNAVAILABLE) uint32_t ret = arm_smc32_call(PSCI_FUNCTION_VERSION, /* unused */ 0, 0, 0); /* the return value has no error codes, but if we get it wrong this is what we will get */ if (ret == PSCI_RETURN_NOT_SUPPORTED) { diff --git a/loader/src/cpus.h b/loader/src/cpus.h index a94f221ec..d01f888e2 100644 --- a/loader/src/cpus.h +++ b/loader/src/cpus.h @@ -11,6 +11,11 @@ #include +#if defined(CONFIG_PLAT_BCM2711) || defined(BOARD_kria_k26) +/* There are a couple of cases where we cannot rely on having ARM PSCI available. */ +#define ARM_PSCI_UNAVAILABLE +#endif + /* Define our own variant of the seL4 config */ #define NUM_ACTIVE_CPUS CONFIG_MAX_NUM_NODES