Skip to content

Commit 05a741a

Browse files
author
Deepika
committed
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 b9e1bc1 commit 05a741a

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

CMSIS/RTOS2/RTX/Source/ARM/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

CMSIS/RTOS2/RTX/Source/GCC/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 non-secure
234235
MRS R0,PSP // Get PSP
235236
STR R0,[R1,#TCB_SP_OFS] // Store SP
236237
B Sys_ContextSave2

CMSIS/RTOS2/RTX/Source/IAR/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 non-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)