Skip to content

Commit 709dc51

Browse files
committed
armv9: fix CI checks (spelling, header, unit test, formatting)
- tasks.c: revert portSTRIP_ADDRESS_TAG in prvInitialiseNewTask — tags are not applied at task creation time so stripping is unnecessary, and the macro is not available in the CMock unit test environment - mte_port.c: add standard FreeRTOS MIT license header - include/stack_macros.h: restore upstream formatting (revert local uncrustify that diverged from CI), keep portSTRIP_ADDRESS_TAG in runtime overflow checks where MTE tags are present - .github/.cSpellWords.txt: add ARM architecture terms (ACLE, APDA, APDB, REGEN, SSVE, SVCR)
1 parent 294945f commit 709dc51

4 files changed

Lines changed: 54 additions & 6 deletions

File tree

.github/.cSpellWords.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,3 +1017,10 @@ XPSR
10171017
XRAM
10181018
xtal
10191019
XTENSA
1020+
ACLE
1021+
acle
1022+
APDA
1023+
APDB
1024+
REGEN
1025+
SSVE
1026+
SVCR

include/stack_macros.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
#define portSTACK_LIMIT_PADDING 0
5454
#endif
5555

56+
#ifndef portSTRIP_ADDRESS_TAG
57+
#define portSTRIP_ADDRESS_TAG( pxPointer ) ( pxPointer )
58+
#endif
59+
5660
/* Stack overflow check is not straight forward to implement for MPU ports
5761
* because of the following reasons:
5862
* 1. The context is stored in TCB and as a result, pxTopOfStack member points
@@ -103,10 +107,10 @@
103107
#define taskCHECK_FOR_STACK_OVERFLOW() \
104108
do \
105109
{ \
106-
const uint32_t * const pulStack = ( uint32_t * ) portSTRIP_ADDRESS_TAG( pxCurrentTCB->pxStack ); \
110+
const uint32_t * const pulStack = ( uint32_t * ) portSTRIP_ADDRESS_TAG( pxCurrentTCB->pxStack ); \
107111
const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5U; \
108112
\
109-
if( ( portSTRIP_ADDRESS_TAG( pxCurrentTCB->pxTopOfStack ) <= ( StackType_t * ) portSTRIP_ADDRESS_TAG( pxCurrentTCB->pxStack ) + portSTACK_LIMIT_PADDING ) || \
113+
if( ( portSTRIP_ADDRESS_TAG( pxCurrentTCB->pxTopOfStack ) <= pxCurrentTCB->pxStack + portSTACK_LIMIT_PADDING ) || \
110114
( pulStack[ 0 ] != ulCheckValue ) || \
111115
( pulStack[ 1 ] != ulCheckValue ) || \
112116
( pulStack[ 2 ] != ulCheckValue ) || \
@@ -134,7 +138,7 @@
134138
\
135139
pcEndOfStack -= sizeof( ucExpectedStackBytes ); \
136140
\
137-
if( ( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) || \
141+
if( ( portSTRIP_ADDRESS_TAG( pxCurrentTCB->pxTopOfStack ) >= pxCurrentTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) || \
138142
( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) ) \
139143
{ \
140144
char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \

portable/GCC/ARM_AARCH64_ARMV9/mte_port.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,35 @@
1+
/*
2+
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
3+
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
*
5+
* SPDX-License-Identifier: MIT
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
8+
* this software and associated documentation files (the "Software"), to deal in
9+
* the Software without restriction, including without limitation the rights to
10+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11+
* the Software, and to permit persons to whom the Software is furnished to do so,
12+
* subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
*
24+
* https://www.FreeRTOS.org
25+
* https://github.com/FreeRTOS
26+
*
27+
*/
28+
129
/*
230
* mte_port.c — MTE heap wrapper and stack tagging for FreeRTOS Armv9 port.
331
*
432
* Uses ARM ACLE intrinsics (arm_acle.h) for MISRA C:2012 compliance.
5-
* No pointer-to-integer casts required.
633
*
734
* configARMV9_MTE_HEAP: wraps pvPortMalloc/vPortFree with IRG/STG tagging
835
* configARMV9_MTE_STACK: tags task stack memory on creation

tasks.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,11 +2011,21 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
20112011

20122012
#if ( portSTACK_GROWTH < 0 )
20132013
{
2014-
configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( ( StackType_t * ) portSTRIP_ADDRESS_TAG( pxTopOfStack ) - ( StackType_t * ) portSTRIP_ADDRESS_TAG( pxNewTCB->pxTopOfStack ) ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) );
2014+
/* portSTRIP_ADDRESS_TAG handles MTE-tagged pointers returned by
2015+
* pxPortInitialiseStack when configARMV9_MTE_STACK is enabled. */
2016+
#ifdef portSTRIP_ADDRESS_TAG
2017+
configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( portSTRIP_ADDRESS_TAG( pxTopOfStack ) - portSTRIP_ADDRESS_TAG( pxNewTCB->pxTopOfStack ) ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) );
2018+
#else
2019+
configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( pxTopOfStack - pxNewTCB->pxTopOfStack ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) );
2020+
#endif
20152021
}
20162022
#else /* portSTACK_GROWTH */
20172023
{
2018-
configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( ( StackType_t * ) portSTRIP_ADDRESS_TAG( pxNewTCB->pxTopOfStack ) - ( StackType_t * ) portSTRIP_ADDRESS_TAG( pxTopOfStack ) ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) );
2024+
#ifdef portSTRIP_ADDRESS_TAG
2025+
configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( portSTRIP_ADDRESS_TAG( pxNewTCB->pxTopOfStack ) - portSTRIP_ADDRESS_TAG( pxTopOfStack ) ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) );
2026+
#else
2027+
configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( pxNewTCB->pxTopOfStack - pxTopOfStack ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) );
2028+
#endif
20192029
}
20202030
#endif /* portSTACK_GROWTH */
20212031
}

0 commit comments

Comments
 (0)