Skip to content

Commit 25f9222

Browse files
armv8.1-m: Remove portHAS_PACBTI_FEATURE macro (#1192)
The PACBTI is an optional hardware security feature, the current implementation assumes that every SoC that has Armv8.1-M architecture extension, has the PACBTI hardware feature, which does not have to be the case. Hence, the `portHAS_PACBTI_FEATURE` is removed and the implementation is modified to rely on `configENABLE_PAC` and `configENABLE_BTI` macros that can either be set using CMake or FreeRTOSConfig.h header file. Enabling PAC and/or BTI on a port variant that doesn't have the PACBTI hardware feature would be caught by a `configASSERT` statement. Signed-off-by: Ahmed Ismail <Ahmed.Ismail@arm.com> Co-authored-by: Tony Josi <tonyjosi@amazon.com>
1 parent 73f6e3a commit 25f9222

File tree

56 files changed

+257
-445
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+257
-445
lines changed

include/FreeRTOS.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3034,14 +3034,12 @@
30343034

30353035
/* Set configENABLE_PAC and/or configENABLE_BTI to 1 to enable PAC and/or BTI
30363036
* support and 0 to disable them. These are currently used in ARMv8.1-M ports. */
3037-
#if ( portHAS_PACBTI_FEATURE == 1 )
3038-
#ifndef configENABLE_PAC
3039-
#define configENABLE_PAC 0
3040-
#endif
3037+
#ifndef configENABLE_PAC
3038+
#define configENABLE_PAC 0
3039+
#endif
30413040

3042-
#ifndef configENABLE_BTI
3043-
#define configENABLE_BTI 0
3044-
#endif
3041+
#ifndef configENABLE_BTI
3042+
#define configENABLE_BTI 0
30453043
#endif
30463044

30473045
/* Sometimes the FreeRTOSConfig.h settings only allow a task to be created using

portable/ARMv8M/non_secure/port.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ typedef void ( * portISR_t )( void );
380380
/**
381381
* @brief Constants required to check and configure PACBTI security feature implementation.
382382
*/
383-
#if ( portHAS_PACBTI_FEATURE == 1 )
383+
#if( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
384384

385385
#define portID_ISAR5_REG ( *( ( volatile uint32_t * ) 0xe000ed74 ) )
386386

@@ -389,7 +389,7 @@ typedef void ( * portISR_t )( void );
389389
#define portCONTROL_UBTI_EN ( 1UL << 5UL )
390390
#define portCONTROL_BTI_EN ( 1UL << 4UL )
391391

392-
#endif /* portHAS_PACBTI_FEATURE */
392+
#endif /* configENABLE_PAC == 1 || configENABLE_BTI == 1 */
393393
/*-----------------------------------------------------------*/
394394

395395
/**
@@ -427,7 +427,7 @@ static void prvTaskExitError( void );
427427
static void prvSetupFPU( void ) PRIVILEGED_FUNCTION;
428428
#endif /* configENABLE_FPU */
429429

430-
#if ( portHAS_PACBTI_FEATURE == 1 )
430+
#if( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
431431

432432
/**
433433
* @brief Configures PACBTI features.
@@ -445,7 +445,7 @@ static void prvTaskExitError( void );
445445
*/
446446
static uint32_t prvConfigurePACBTI( BaseType_t xWriteControlRegister );
447447

448-
#endif /* portHAS_PACBTI_FEATURE */
448+
#endif /* configENABLE_PAC == 1 || configENABLE_BTI == 1 */
449449

450450
/**
451451
* @brief Setup the timer to generate the tick interrupts.
@@ -1541,13 +1541,13 @@ void vPortSVCHandler_C( uint32_t * pulCallerStackAddress ) /* PRIVILEGED_FUNCTIO
15411541
xMPUSettings->ulContext[ ulIndex ] = ( uint32_t ) pxEndOfStack; /* PSPLIM. */
15421542
ulIndex++;
15431543

1544-
#if ( portHAS_PACBTI_FEATURE == 1 )
1544+
#if( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
15451545
{
15461546
/* Check PACBTI security feature configuration before pushing the
15471547
* CONTROL register's value on task's TCB. */
15481548
ulControl = prvConfigurePACBTI( pdFALSE );
15491549
}
1550-
#endif /* portHAS_PACBTI_FEATURE */
1550+
#endif /* configENABLE_PAC == 1 || configENABLE_BTI == 1 */
15511551

15521552
if( xRunPrivileged == pdTRUE )
15531553
{
@@ -1786,13 +1786,13 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */
17861786
portNVIC_SHPR3_REG |= portNVIC_SYSTICK_PRI;
17871787
portNVIC_SHPR2_REG = 0;
17881788

1789-
#if ( portHAS_PACBTI_FEATURE == 1 )
1789+
#if( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
17901790
{
17911791
/* Set the CONTROL register value based on PACBTI security feature
17921792
* configuration before starting the first task. */
17931793
( void) prvConfigurePACBTI( pdTRUE );
17941794
}
1795-
#endif /* portHAS_PACBTI_FEATURE */
1795+
#endif /* configENABLE_PAC == 1 || configENABLE_BTI == 1 */
17961796

17971797
#if ( configENABLE_MPU == 1 )
17981798
{
@@ -2213,7 +2213,7 @@ BaseType_t xPortIsInsideInterrupt( void )
22132213
#endif /* #if ( ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) ) */
22142214
/*-----------------------------------------------------------*/
22152215

2216-
#if ( portHAS_PACBTI_FEATURE == 1 )
2216+
#if( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
22172217

22182218
static uint32_t prvConfigurePACBTI( BaseType_t xWriteControlRegister )
22192219
{
@@ -2222,12 +2222,8 @@ BaseType_t xPortIsInsideInterrupt( void )
22222222
/* Ensure that PACBTI is implemented. */
22232223
configASSERT( portID_ISAR5_REG != 0x0 );
22242224

2225-
/* Enable UsageFault exception if PAC or BTI is enabled. */
2226-
#if( ( configENABLE_PAC == 1 ) || ( configENABLE_BTI == 1 ) )
2227-
{
2228-
portSCB_SYS_HANDLER_CTRL_STATE_REG |= portSCB_USG_FAULT_ENABLE_BIT;
2229-
}
2230-
#endif
2225+
/* Enable UsageFault exception. */
2226+
portSCB_SYS_HANDLER_CTRL_STATE_REG |= portSCB_USG_FAULT_ENABLE_BIT;
22312227

22322228
#if( configENABLE_PAC == 1 )
22332229
{
@@ -2249,5 +2245,5 @@ BaseType_t xPortIsInsideInterrupt( void )
22492245
return ulControl;
22502246
}
22512247

2252-
#endif /* #if ( portHAS_PACBTI_FEATURE == 1 ) */
2248+
#endif /* configENABLE_PAC == 1 || configENABLE_BTI == 1 */
22532249
/*-----------------------------------------------------------*/

portable/ARMv8M/non_secure/portable/GCC/ARM_CM23/portmacro.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
* Copyright 2024 Arm Limited and/or its affiliates
5-
* <open-source-office@arm.com>
64
*
75
* SPDX-License-Identifier: MIT
86
*
@@ -53,7 +51,6 @@
5351
#define portARCH_NAME "Cortex-M23"
5452
#define portHAS_ARMV8M_MAIN_EXTENSION 0
5553
#define portARMV8M_MINOR_VERSION 0
56-
#define portHAS_PACBTI_FEATURE 0
5754
#define portDONT_DISCARD __attribute__( ( used ) )
5855
/*-----------------------------------------------------------*/
5956

portable/ARMv8M/non_secure/portable/GCC/ARM_CM23_NTZ/portmacro.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
* Copyright 2024 Arm Limited and/or its affiliates
5-
* <open-source-office@arm.com>
64
*
75
* SPDX-License-Identifier: MIT
86
*
@@ -53,7 +51,6 @@
5351
#define portARCH_NAME "Cortex-M23"
5452
#define portHAS_ARMV8M_MAIN_EXTENSION 0
5553
#define portARMV8M_MINOR_VERSION 0
56-
#define portHAS_PACBTI_FEATURE 0
5754
#define portDONT_DISCARD __attribute__( ( used ) )
5855
/*-----------------------------------------------------------*/
5956

portable/ARMv8M/non_secure/portable/GCC/ARM_CM33/portmacro.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
* Copyright 2024 Arm Limited and/or its affiliates
5-
* <open-source-office@arm.com>
64
*
75
* SPDX-License-Identifier: MIT
86
*
@@ -53,7 +51,6 @@
5351
#define portARCH_NAME "Cortex-M33"
5452
#define portHAS_ARMV8M_MAIN_EXTENSION 1
5553
#define portARMV8M_MINOR_VERSION 0
56-
#define portHAS_PACBTI_FEATURE 0
5754
#define portDONT_DISCARD __attribute__( ( used ) )
5855
/*-----------------------------------------------------------*/
5956

portable/ARMv8M/non_secure/portable/GCC/ARM_CM33_NTZ/portmacro.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
* Copyright 2024 Arm Limited and/or its affiliates
5-
* <open-source-office@arm.com>
64
*
75
* SPDX-License-Identifier: MIT
86
*
@@ -53,7 +51,6 @@
5351
#define portARCH_NAME "Cortex-M33"
5452
#define portHAS_ARMV8M_MAIN_EXTENSION 1
5553
#define portARMV8M_MINOR_VERSION 0
56-
#define portHAS_PACBTI_FEATURE 0
5754
#define portDONT_DISCARD __attribute__( ( used ) )
5855
/*-----------------------------------------------------------*/
5956

portable/ARMv8M/non_secure/portable/GCC/ARM_CM35P/portmacro.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
* Copyright 2024 Arm Limited and/or its affiliates
5-
* <open-source-office@arm.com>
64
*
75
* SPDX-License-Identifier: MIT
86
*
@@ -53,7 +51,6 @@
5351
#define portARCH_NAME "Cortex-M35P"
5452
#define portHAS_ARMV8M_MAIN_EXTENSION 1
5553
#define portARMV8M_MINOR_VERSION 0
56-
#define portHAS_PACBTI_FEATURE 0
5754
#define portDONT_DISCARD __attribute__( ( used ) )
5855
/*-----------------------------------------------------------*/
5956

portable/ARMv8M/non_secure/portable/GCC/ARM_CM55/portmacro.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
* Copyright 2024 Arm Limited and/or its affiliates
5-
* <open-source-office@arm.com>
64
*
75
* SPDX-License-Identifier: MIT
86
*
@@ -58,7 +56,6 @@
5856
#define portARCH_NAME "Cortex-M55"
5957
#define portHAS_ARMV8M_MAIN_EXTENSION 1
6058
#define portARMV8M_MINOR_VERSION 1
61-
#define portHAS_PACBTI_FEATURE 0
6259
#define portDONT_DISCARD __attribute__( ( used ) )
6360
/*-----------------------------------------------------------*/
6461

portable/ARMv8M/non_secure/portable/GCC/ARM_CM85/portmacro.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
* Copyright 2024 Arm Limited and/or its affiliates
5-
* <open-source-office@arm.com>
64
*
75
* SPDX-License-Identifier: MIT
86
*
@@ -58,7 +56,6 @@
5856
#define portARCH_NAME "Cortex-M85"
5957
#define portHAS_ARMV8M_MAIN_EXTENSION 1
6058
#define portARMV8M_MINOR_VERSION 1
61-
#define portHAS_PACBTI_FEATURE 1
6259
#define portDONT_DISCARD __attribute__( ( used ) )
6360
/*-----------------------------------------------------------*/
6461

portable/ARMv8M/non_secure/portable/IAR/ARM_CM23/portmacro.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
* Copyright 2024 Arm Limited and/or its affiliates
5-
* <open-source-office@arm.com>
64
*
75
* SPDX-License-Identifier: MIT
86
*
@@ -53,7 +51,6 @@
5351
#define portARCH_NAME "Cortex-M23"
5452
#define portHAS_ARMV8M_MAIN_EXTENSION 0
5553
#define portARMV8M_MINOR_VERSION 0
56-
#define portHAS_PACBTI_FEATURE 0
5754
#define portDONT_DISCARD __root
5855
/*-----------------------------------------------------------*/
5956

portable/ARMv8M/non_secure/portable/IAR/ARM_CM23_NTZ/portmacro.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
* Copyright 2024 Arm Limited and/or its affiliates
5-
* <open-source-office@arm.com>
64
*
75
* SPDX-License-Identifier: MIT
86
*
@@ -53,7 +51,6 @@
5351
#define portARCH_NAME "Cortex-M23"
5452
#define portHAS_ARMV8M_MAIN_EXTENSION 0
5553
#define portARMV8M_MINOR_VERSION 0
56-
#define portHAS_PACBTI_FEATURE 0
5754
#define portDONT_DISCARD __root
5855
/*-----------------------------------------------------------*/
5956

portable/ARMv8M/non_secure/portable/IAR/ARM_CM33/portmacro.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
* Copyright 2024 Arm Limited and/or its affiliates
5-
* <open-source-office@arm.com>
64
*
75
* SPDX-License-Identifier: MIT
86
*
@@ -53,7 +51,6 @@
5351
#define portARCH_NAME "Cortex-M33"
5452
#define portHAS_ARMV8M_MAIN_EXTENSION 1
5553
#define portARMV8M_MINOR_VERSION 0
56-
#define portHAS_PACBTI_FEATURE 0
5754
#define portDONT_DISCARD __root
5855
/*-----------------------------------------------------------*/
5956

portable/ARMv8M/non_secure/portable/IAR/ARM_CM33_NTZ/portmacro.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
* Copyright 2024 Arm Limited and/or its affiliates
5-
* <open-source-office@arm.com>
64
*
75
* SPDX-License-Identifier: MIT
86
*
@@ -53,7 +51,6 @@
5351
#define portARCH_NAME "Cortex-M33"
5452
#define portHAS_ARMV8M_MAIN_EXTENSION 1
5553
#define portARMV8M_MINOR_VERSION 0
56-
#define portHAS_PACBTI_FEATURE 0
5754
#define portDONT_DISCARD __root
5855
/*-----------------------------------------------------------*/
5956

portable/ARMv8M/non_secure/portable/IAR/ARM_CM35P/portmacro.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
* Copyright 2024 Arm Limited and/or its affiliates
5-
* <open-source-office@arm.com>
64
*
75
* SPDX-License-Identifier: MIT
86
*
@@ -53,7 +51,6 @@
5351
#define portARCH_NAME "Cortex-M35P"
5452
#define portHAS_ARMV8M_MAIN_EXTENSION 1
5553
#define portARMV8M_MINOR_VERSION 0
56-
#define portHAS_PACBTI_FEATURE 0
5754
#define portDONT_DISCARD __root
5855
/*-----------------------------------------------------------*/
5956

portable/ARMv8M/non_secure/portable/IAR/ARM_CM55/portmacro.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
* Copyright 2024 Arm Limited and/or its affiliates
5-
* <open-source-office@arm.com>
64
*
75
* SPDX-License-Identifier: MIT
86
*
@@ -58,7 +56,6 @@
5856
#define portARCH_NAME "Cortex-M55"
5957
#define portHAS_ARMV8M_MAIN_EXTENSION 1
6058
#define portARMV8M_MINOR_VERSION 1
61-
#define portHAS_PACBTI_FEATURE 0
6259
#define portDONT_DISCARD __root
6360
/*-----------------------------------------------------------*/
6461

portable/ARMv8M/non_secure/portable/IAR/ARM_CM85/portmacro.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/*
22
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
33
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
* Copyright 2024 Arm Limited and/or its affiliates
5-
* <open-source-office@arm.com>
64
*
75
* SPDX-License-Identifier: MIT
86
*
@@ -58,7 +56,6 @@
5856
#define portARCH_NAME "Cortex-M85"
5957
#define portHAS_ARMV8M_MAIN_EXTENSION 1
6058
#define portARMV8M_MINOR_VERSION 1
61-
#define portHAS_PACBTI_FEATURE 1
6259
#define portDONT_DISCARD __root
6360
/*-----------------------------------------------------------*/
6461

0 commit comments

Comments
 (0)