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.
This commit is contained in:
Sebastian Huber
2024-10-04 03:48:18 +02:00
parent 1524b5f923
commit 5ff5bd3c10
2 changed files with 20 additions and 13 deletions

View File

@@ -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).

View File

@@ -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();
}