Skip to content

Commit 50e77c2

Browse files
Dat-NguyenDuycarlescufi
authored andcommitted
arch: arm: aarch32: cortex_a_r: disable interrupts before context switching
Ultil now Cortex A/R aarch32 implementation for context switching expects that interrupts was disabled. This is true if a context switching happens at thread context. But if a context switching happens at last action during interrupt context, this assumption is not true because the interrupts are still enabled (to allow nesting interrupts). Disable interrupts at the last interrupt action to ensure the interrupts are always disabled before context switching is processed Signed-off-by: Dat Nguyen Duy <[email protected]>
1 parent b94ab6e commit 50e77c2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arch/arm/core/aarch32/cortex_a_r/exc_exit.S

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ SECTION_SUBSEC_FUNC(TEXT, _HandlerModeExit, z_arm_int_exit)
129129
bl z_check_stack_sentinel
130130
#endif /* CONFIG_STACK_SENTINEL */
131131

132+
/* Disable nested interrupts while exiting, this should happens
133+
* before context switch also, to ensure interrupts are disabled.
134+
*/
135+
cpsid i
136+
132137
#ifdef CONFIG_PREEMPT_ENABLED
133138
/* Do not context switch if exiting a nested interrupt */
134139
ldr r3, =_kernel
@@ -143,9 +148,6 @@ SECTION_SUBSEC_FUNC(TEXT, _HandlerModeExit, z_arm_int_exit)
143148
__EXIT_INT:
144149
#endif /* CONFIG_PREEMPT_ENABLED */
145150

146-
/* Disable nested interrupts while exiting */
147-
cpsid i
148-
149151
/* Decrement interrupt nesting count */
150152
ldr r2, =_kernel
151153
ldr r0, [r2, #_kernel_offset_to_nested]

0 commit comments

Comments
 (0)