diff --git a/arch/arm/core/aarch32/cortex_a_r/exc_exit.S b/arch/arm/core/aarch32/cortex_a_r/exc_exit.S index d10c9f7ce67..2978f64ae0e 100644 --- a/arch/arm/core/aarch32/cortex_a_r/exc_exit.S +++ b/arch/arm/core/aarch32/cortex_a_r/exc_exit.S @@ -129,6 +129,11 @@ SECTION_SUBSEC_FUNC(TEXT, _HandlerModeExit, z_arm_int_exit) bl z_check_stack_sentinel #endif /* CONFIG_STACK_SENTINEL */ + /* Disable nested interrupts while exiting, this should happens + * before context switch also, to ensure interrupts are disabled. + */ + cpsid i + #ifdef CONFIG_PREEMPT_ENABLED /* Do not context switch if exiting a nested interrupt */ ldr r3, =_kernel @@ -143,9 +148,6 @@ SECTION_SUBSEC_FUNC(TEXT, _HandlerModeExit, z_arm_int_exit) __EXIT_INT: #endif /* CONFIG_PREEMPT_ENABLED */ - /* Disable nested interrupts while exiting */ - cpsid i - /* Decrement interrupt nesting count */ ldr r2, =_kernel ldr r0, [r2, #_kernel_offset_to_nested]