Skip to content

Commit 6c6df4f

Browse files
committed
tasks: Disable stack-depth check if MPU wrappers is set
This stack-depth check should not be performed for ports where portUSING_MPU_WRAPPERS is set to 1. In this case, pxTopOfStack and pxNewTCB->pxTopOfStack reside in different memory regions: pxTopOfStack is in unprivileged SRAM, while pxNewTCB->pxTopOfStack is in privileged SRAM. This is because pxPortInitialiseStack() returns the address of `ullContext` array rather than the decremented pxTopOfStack, as is done in the non-MPU case. Consequently, this check is not valid in this scenario. Signed-off-by: Ahmed Ismail <[email protected]>
1 parent 87611a5 commit 6c6df4f

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

.github/scripts/kernel_checker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
r'.*portable/.*/ARM_CM4F_MPU*',
121121
r'.*portable/.*/ARM_CR82*',
122122
r'.*include/task\.h$',
123+
r'.*tasks\.c$',
123124
]
124125

125126
KERNEL_HEADER = [

tasks.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
* Copyright 2026 Arm Limited and/or its affiliates <[email protected]>
45
*
56
* SPDX-License-Identifier: MIT
67
*
@@ -2007,18 +2008,18 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
20072008
pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters );
20082009
}
20092010
#endif /* portHAS_STACK_OVERFLOW_CHECKING */
2010-
}
2011-
#endif /* portUSING_MPU_WRAPPERS */
20122011

2013-
#if ( portSTACK_GROWTH < 0 )
2014-
{
2015-
configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( pxTopOfStack - pxNewTCB->pxTopOfStack ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) );
2016-
}
2017-
#else /* portSTACK_GROWTH */
2018-
{
2019-
configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( pxNewTCB->pxTopOfStack - pxTopOfStack ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) );
2012+
#if ( portSTACK_GROWTH < 0 )
2013+
{
2014+
configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( pxTopOfStack - pxNewTCB->pxTopOfStack ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) );
2015+
}
2016+
#else /* portSTACK_GROWTH */
2017+
{
2018+
configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( pxNewTCB->pxTopOfStack - pxTopOfStack ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) );
2019+
}
2020+
#endif /* portSTACK_GROWTH */
20202021
}
2021-
#endif
2022+
#endif /* portUSING_MPU_WRAPPERS */
20222023

20232024
/* Initialize task state and task attributes. */
20242025
#if ( configNUMBER_OF_CORES > 1 )

0 commit comments

Comments
 (0)