Skip to content

Commit cf65e2b

Browse files
author
Deepika
committed
Pulling in CMSIS commit 05fa9d3
Systick handler switch to secure/nonsecure issues addressed: 1. Switch to secure/nonsecure context save/restore is based on 6th bit in LR register, correct the bug (R7 instead of LR was used for decision) 2. Prevent R7 from being corrupted in Sys_ContextSave 3. Branch when non-secure rather than secure
1 parent 4076788 commit cf65e2b

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

rtos/TARGET_CORTEX/rtx5/RTX/Source/TOOLCHAIN_ARM/TARGET_M23/irq_armv8mbl.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,9 @@ Sys_ContextSave
225225
BL TZ_StoreContext_S ; Store secure context
226226
MOV LR,R7 ; Set EXC_RETURN
227227
POP {R1,R2,R3,R7} ; Restore registers
228-
LSLS R7,R7,#25 ; Check domain of interrupted thread
229-
BMI Sys_ContextSave1 ; Branch if secure
228+
MOV R0,LR ; Get EXC_RETURN
229+
LSLS R0,R0,#25 ; Check domain of interrupted thread
230+
BPL Sys_ContextSave1 ; Branch if non-secure
230231
MRS R0,PSP ; Get PSP
231232
STR R0,[R1,#TCB_SP_OFS] ; Store SP
232233
B Sys_ContextSave2

rtos/TARGET_CORTEX/rtx5/RTX/Source/TOOLCHAIN_GCC/TARGET_M23/irq_armv8mbl.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,9 @@ Sys_ContextSave:
229229
BL TZ_StoreContext_S // Store secure context
230230
MOV LR,R7 // Set EXC_RETURN
231231
POP {R1,R2,R3,R7} // Restore registers
232-
LSLS R7,R7,#25 // Check domain of interrupted thread
233-
BMI Sys_ContextSave1 // Branch if secure
232+
MOV R0,LR // Get EXC_RETURN
233+
LSLS R0,R0,#25 // Check domain of interrupted thread
234+
BPL Sys_ContextSave1 // Branch if not secure
234235
MRS R0,PSP // Get PSP
235236
STR R0,[R1,#TCB_SP_OFS] // Store SP
236237
B Sys_ContextSave2

rtos/TARGET_CORTEX/rtx5/RTX/Source/TOOLCHAIN_IAR/TARGET_M23/irq_armv8mbl_common.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,9 @@ Sys_ContextSave
218218
BL TZ_StoreContext_S ; Store secure context
219219
MOV LR,R7 ; Set EXC_RETURN
220220
POP {R1,R2,R3,R7} ; Restore registers
221-
LSLS R7,R7,#25 ; Check domain of interrupted thread
222-
BMI Sys_ContextSave1 ; Branch if secure
221+
MOV R0,LR ; Get EXC_RETURN
222+
LSLS R0,R0,#25 ; Check domain of interrupted thread
223+
BPL Sys_ContextSave1 ; Branch if not secure
223224
MRS R0,PSP ; Get PSP
224225
STR R0,[R1,#TCB_SP_OFS] ; Store SP
225226
B Sys_ContextSave2

0 commit comments

Comments
 (0)