From 5ff5bd3c109e3bb8c2bc2bd3fa18a98a784f8e38 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 4 Oct 2024 03:48:18 +0200 Subject: [PATCH] aarch64: More robust SMP system start In SMP configurations, check that we run on a configured processor. If not, then there is not much that can be done since we do not have a stack available for this processor. Just loop forever in this case. Do this in assemlby to ensure that no stack memory is used. --- bsps/aarch64/shared/start/start.S | 18 ++++++++++++++++++ .../xilinx-zynqmp/start/bspstarthooks.c | 15 ++------------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/bsps/aarch64/shared/start/start.S b/bsps/aarch64/shared/start/start.S index f3038c81cd..0a89d85035 100644 --- a/bsps/aarch64/shared/start/start.S +++ b/bsps/aarch64/shared/start/start.S @@ -230,6 +230,24 @@ _start: #ifdef RTEMS_SMP bl _AArch64_Get_current_processor_for_system_start + /* + * Check that this is a configured processor. If not, then there is + * not much that can be done since we do not have a stack available for + * this processor. Just loop forever in this case. + */ +#ifdef AARCH64_MULTILIB_ARCH_V8_ILP32 + ldr w1, =_SMP_Processor_configured_maximum +#else + ldr x1, =_SMP_Processor_configured_maximum +#endif + ldr w1, [x1] + cmp x1, x0 + bgt .Lconfigured_processor +.Linvalid_processor_wait_for_ever: + wfe + b .Linvalid_processor_wait_for_ever +.Lconfigured_processor: + /* * Get current per-CPU control and store it in PL1 only Thread ID * Register (TPIDR_EL1). diff --git a/bsps/aarch64/xilinx-zynqmp/start/bspstarthooks.c b/bsps/aarch64/xilinx-zynqmp/start/bspstarthooks.c index 340fb6d140..fb21936745 100644 --- a/bsps/aarch64/xilinx-zynqmp/start/bspstarthooks.c +++ b/bsps/aarch64/xilinx-zynqmp/start/bspstarthooks.c @@ -54,24 +54,14 @@ BSP_START_TEXT_SECTION void bsp_start_hook_0( void ) BSP_START_TEXT_SECTION void bsp_start_hook_1( void ) { + AArch64_start_set_vector_base(); + #ifdef RTEMS_SMP uint32_t cpu_index_self; cpu_index_self = _SMP_Get_current_processor(); if ( cpu_index_self != 0 ) { - if ( - cpu_index_self >= rtems_configuration_get_maximum_processors() - || !_SMP_Should_start_processor( cpu_index_self ) - ) { - while ( true ) { - _AARCH64_Wait_for_event(); - } - } - - /* Change the VBAR from the start to the normal vector table */ - AArch64_start_set_vector_base(); - zynqmp_setup_secondary_cpu_mmu_and_cache(); arm_gic_irq_initialize_secondary_cpu(); @@ -83,7 +73,6 @@ BSP_START_TEXT_SECTION void bsp_start_hook_1( void ) } #endif /* RTEMS_SMP */ - AArch64_start_set_vector_base(); zynqmp_setup_mmu_and_cache(); bsp_start_clear_bss(); }