From 32f0f11a68d3aa521f0398c9b8eec3d47f114c5e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 8 Mar 2022 16:56:49 +0100 Subject: SMP: Fix start multitasking for some targets The previous SMP multitasking start assumed that the initial heir thread of a processor starts execution in _Thread_Handler(). The _Thread_Handler() sets the interrupt state explicitly by _ISR_Set_level() before it calls the thread entry. Under certain timing conditions, processors may perform an initial context switch to a thread which already executes its thread body (see smptests/smpstart01). In this case, interrupts are disabled after the context switch on targets which do not save/restore the interrupt state during a context switch (aarch64, arm, and riscv). Close #4627. --- cpukit/score/cpu/arm/cpu_asm.S | 12 ++++++++++++ cpukit/score/cpu/arm/include/rtems/score/cpu.h | 4 ++++ 2 files changed, 16 insertions(+) (limited to 'cpukit/score/cpu/arm') diff --git a/cpukit/score/cpu/arm/cpu_asm.S b/cpukit/score/cpu/arm/cpu_asm.S index 54d6f70b0d..d52a43f70d 100644 --- a/cpukit/score/cpu/arm/cpu_asm.S +++ b/cpukit/score/cpu/arm/cpu_asm.S @@ -181,6 +181,18 @@ DEFINE_FUNCTION_ARM(_CPU_Context_restore) /* Update the executing */ str r5, [r2, #PER_CPU_OFFSET_EXECUTING] + b .L_check_is_executing + +DEFINE_FUNCTION_ARM(_ARM_Start_multitasking) + mov r1, r0 + GET_SELF_CPU_CONTROL r2 + + /* Switch the stack to the temporary interrupt stack of this processor */ + add sp, r2, #(PER_CPU_INTERRUPT_FRAME_AREA + CPU_INTERRUPT_FRAME_SIZE) + + /* Enable IRQ interrupts */ + cpsie i + b .L_check_is_executing #endif diff --git a/cpukit/score/cpu/arm/include/rtems/score/cpu.h b/cpukit/score/cpu/arm/include/rtems/score/cpu.h index da521528a4..7ac180ac26 100644 --- a/cpukit/score/cpu/arm/include/rtems/score/cpu.h +++ b/cpukit/score/cpu/arm/include/rtems/score/cpu.h @@ -443,6 +443,10 @@ void _CPU_Context_Initialize( { context->is_executing = is_executing; } + + RTEMS_NO_RETURN void _ARM_Start_multitasking( Context_Control *heir ); + + #define _CPU_Start_multitasking( _heir ) _ARM_Start_multitasking( _heir ) #endif #define _CPU_Context_Restart_self( _the_context ) \ -- cgit v1.2.3