Skip to content

Commit 8341ffd

Browse files
committed
Fix free secure context for Cortex-M23 ports
Update the branching condition to correctly free secure context when there is one. Signed-off-by: Gaurav Aggarwal <[email protected]>
1 parent faa92f7 commit 8341ffd

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

portable/ARMv8M/non_secure/portable/GCC/ARM_CM23/portasm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ void vPortFreeSecureContext( uint32_t * pulTCB ) /* __attribute__ (( naked )) PR
448448
" ldr r2, [r0] \n"/* The first item in the TCB is the top of the stack. */
449449
" ldr r1, [r2] \n"/* The first item on the stack is the task's xSecureContext. */
450450
" cmp r1, #0 \n"/* Raise svc if task's xSecureContext is not NULL. */
451-
" beq free_secure_context \n"
451+
" bne free_secure_context \n"/* Branch if r1 != 0. */
452452
" bx lr \n"/* There is no secure context (xSecureContext is NULL). */
453453
" free_secure_context: \n"
454454
" svc %0 \n"/* Secure context is freed in the supervisor call. */

portable/ARMv8M/non_secure/portable/IAR/ARM_CM23/portasm.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ vPortFreeSecureContext:
380380
ldr r2, [r0] /* The first item in the TCB is the top of the stack. */
381381
ldr r1, [r2] /* The first item on the stack is the task's xSecureContext. */
382382
cmp r1, #0 /* Raise svc if task's xSecureContext is not NULL. */
383-
beq free_secure_context
383+
bne free_secure_context /* Branch if r1 != 0. */
384384
bx lr /* There is no secure context (xSecureContext is NULL). */
385385
free_secure_context:
386386
svc 1 /* Secure context is freed in the supervisor call. portSVC_FREE_SECURE_CONTEXT = 1. */

portable/GCC/ARM_CM23/non_secure/portasm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ void vPortFreeSecureContext( uint32_t * pulTCB ) /* __attribute__ (( naked )) PR
448448
" ldr r2, [r0] \n"/* The first item in the TCB is the top of the stack. */
449449
" ldr r1, [r2] \n"/* The first item on the stack is the task's xSecureContext. */
450450
" cmp r1, #0 \n"/* Raise svc if task's xSecureContext is not NULL. */
451-
" beq free_secure_context \n"
451+
" bne free_secure_context \n"/* Branch if r1 != 0. */
452452
" bx lr \n"/* There is no secure context (xSecureContext is NULL). */
453453
" free_secure_context: \n"
454454
" svc %0 \n"/* Secure context is freed in the supervisor call. */

portable/IAR/ARM_CM23/non_secure/portasm.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ vPortFreeSecureContext:
380380
ldr r2, [r0] /* The first item in the TCB is the top of the stack. */
381381
ldr r1, [r2] /* The first item on the stack is the task's xSecureContext. */
382382
cmp r1, #0 /* Raise svc if task's xSecureContext is not NULL. */
383-
beq free_secure_context
383+
bne free_secure_context /* Branch if r1 != 0. */
384384
bx lr /* There is no secure context (xSecureContext is NULL). */
385385
free_secure_context:
386386
svc 1 /* Secure context is freed in the supervisor call. portSVC_FREE_SECURE_CONTEXT = 1. */

tasks.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,6 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
12161216
{
12171217
--uxCurrentNumberOfTasks;
12181218
traceTASK_DELETE( pxTCB );
1219-
prvDeleteTCB( pxTCB );
12201219

12211220
/* Reset the next expected unblock time in case it referred to
12221221
* the task that has just been deleted. */
@@ -1225,6 +1224,14 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
12251224
}
12261225
taskEXIT_CRITICAL();
12271226

1227+
/* If the task is not deleting itself, call prvDeleteTCB from outside of
1228+
* critical section. If a task deletes itself, prvDeleteTCB is called
1229+
* from prvCheckTasksWaitingTermination which is called from Idle task. */
1230+
if( pxTCB != pxCurrentTCB )
1231+
{
1232+
prvDeleteTCB( pxTCB );
1233+
}
1234+
12281235
/* Force a reschedule if it is the currently running task that has just
12291236
* been deleted. */
12301237
if( xSchedulerRunning != pdFALSE )

0 commit comments

Comments
 (0)