-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
armv8-m: Do not overwrite Control register value
The current ARMv8-M FreeRTOS-Kernel Port code implementation is modified in a way that allows the CONTROL register's value to be retained rather than being overwritten. This is needed for adding PACBTI support as the special-purpose CONTROL register `PAC_EN`, `UPAC_EN`, `BTI_EN`, and `UBTI_EN` PACBTI enablement bits should be configured before calling `vRestoreContextOfFirstTask()` function which currently overwrite the value inside the CONTROL register. Signed-off-by: Ahmed Ismail <[email protected]>
- Loading branch information
1 parent
950fdf4
commit 53e9117
Showing
10 changed files
with
50 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/* | ||
* FreeRTOS Kernel <DEVELOPMENT BRANCH> | ||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* Copyright 2024 Arm Limited and/or its affiliates | ||
* <[email protected]> | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
|
@@ -130,8 +132,9 @@ | |
" \n" | ||
" ldm r0!, {r1-r2} \n" /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ | ||
" msr psplim, r1 \n" /* Set this task's PSPLIM value. */ | ||
" movs r1, #2 \n" /* r1 = 2. */ | ||
" msr CONTROL, r1 \n" /* Switch to use PSP in the thread mode. */ | ||
" mrs r3, control \n" /* Obtain current control register value. */ | ||
" orrs r3, r3, #2 \n" /* r3 = r3 | 0x2. */ | ||
" msr control, r3 \n" /* Write back the new control register value. */ | ||
" adds r0, #32 \n" /* Discard everything up to r0. */ | ||
" msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ | ||
" isb \n" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/* | ||
* FreeRTOS Kernel <DEVELOPMENT BRANCH> | ||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* Copyright 2024 Arm Limited and/or its affiliates | ||
* <[email protected]> | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
|
@@ -165,8 +167,9 @@ vRestoreContextOfFirstTask: | |
|
||
ldm r0!, {r1-r2} /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ | ||
msr psplim, r1 /* Set this task's PSPLIM value. */ | ||
movs r1, #2 /* r1 = 2. */ | ||
msr CONTROL, r1 /* Switch to use PSP in the thread mode. */ | ||
mrs r3, control /* Obtain current control register value. */ | ||
orrs r3, r3, #2 /* r3 = r3 | 0x2 */ | ||
msr control, r3 /* Write back the new control register value. */ | ||
adds r0, #32 /* Discard everything up to r0. */ | ||
msr psp, r0 /* This is now the new top of stack to use in the task. */ | ||
isb | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/* | ||
* FreeRTOS Kernel <DEVELOPMENT BRANCH> | ||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* Copyright 2024 Arm Limited and/or its affiliates | ||
* <[email protected]> | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
|
@@ -130,8 +132,9 @@ | |
" \n" | ||
" ldm r0!, {r1-r2} \n" /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ | ||
" msr psplim, r1 \n" /* Set this task's PSPLIM value. */ | ||
" movs r1, #2 \n" /* r1 = 2. */ | ||
" msr CONTROL, r1 \n" /* Switch to use PSP in the thread mode. */ | ||
" mrs r3, control \n" /* Obtain current control register value. */ | ||
" orrs r3, r3, #2 \n" /* r3 = r3 | 0x2. */ | ||
" msr control, r3 \n" /* Write back the new control register value. */ | ||
" adds r0, #32 \n" /* Discard everything up to r0. */ | ||
" msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ | ||
" isb \n" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/* | ||
* FreeRTOS Kernel <DEVELOPMENT BRANCH> | ||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* Copyright 2024 Arm Limited and/or its affiliates | ||
* <[email protected]> | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
|
@@ -130,8 +132,9 @@ | |
" \n" | ||
" ldm r0!, {r1-r2} \n" /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ | ||
" msr psplim, r1 \n" /* Set this task's PSPLIM value. */ | ||
" movs r1, #2 \n" /* r1 = 2. */ | ||
" msr CONTROL, r1 \n" /* Switch to use PSP in the thread mode. */ | ||
" mrs r3, control \n" /* Obtain current control register value. */ | ||
" orrs r3, r3, #2 \n" /* r3 = r3 | 0x2. */ | ||
" msr control, r3 \n" /* Write back the new control register value. */ | ||
" adds r0, #32 \n" /* Discard everything up to r0. */ | ||
" msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ | ||
" isb \n" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/* | ||
* FreeRTOS Kernel <DEVELOPMENT BRANCH> | ||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* Copyright 2024 Arm Limited and/or its affiliates | ||
* <[email protected]> | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
|
@@ -130,8 +132,9 @@ | |
" \n" | ||
" ldm r0!, {r1-r2} \n" /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ | ||
" msr psplim, r1 \n" /* Set this task's PSPLIM value. */ | ||
" movs r1, #2 \n" /* r1 = 2. */ | ||
" msr CONTROL, r1 \n" /* Switch to use PSP in the thread mode. */ | ||
" mrs r3, control \n" /* Obtain current control register value. */ | ||
" orrs r3, r3, #2 \n" /* r3 = r3 | 0x2. */ | ||
" msr control, r3 \n" /* Write back the new control register value. */ | ||
" adds r0, #32 \n" /* Discard everything up to r0. */ | ||
" msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ | ||
" isb \n" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/* | ||
* FreeRTOS Kernel <DEVELOPMENT BRANCH> | ||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* Copyright 2024 Arm Limited and/or its affiliates | ||
* <[email protected]> | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
|
@@ -130,8 +132,9 @@ | |
" \n" | ||
" ldm r0!, {r1-r2} \n" /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ | ||
" msr psplim, r1 \n" /* Set this task's PSPLIM value. */ | ||
" movs r1, #2 \n" /* r1 = 2. */ | ||
" msr CONTROL, r1 \n" /* Switch to use PSP in the thread mode. */ | ||
" mrs r3, control \n" /* Obtain current control register value. */ | ||
" orrs r3, r3, #2 \n" /* r3 = r3 | 0x2. */ | ||
" msr control, r3 \n" /* Write back the new control register value. */ | ||
" adds r0, #32 \n" /* Discard everything up to r0. */ | ||
" msr psp, r0 \n" /* This is now the new top of stack to use in the task. */ | ||
" isb \n" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/* | ||
* FreeRTOS Kernel <DEVELOPMENT BRANCH> | ||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* Copyright 2024 Arm Limited and/or its affiliates | ||
* <[email protected]> | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
|
@@ -165,8 +167,9 @@ vRestoreContextOfFirstTask: | |
|
||
ldm r0!, {r1-r2} /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ | ||
msr psplim, r1 /* Set this task's PSPLIM value. */ | ||
movs r1, #2 /* r1 = 2. */ | ||
msr CONTROL, r1 /* Switch to use PSP in the thread mode. */ | ||
mrs r3, control /* Obtain current control register value. */ | ||
orrs r3, r3, #2 /* r3 = r3 | 0x2 */ | ||
msr control, r3 /* Write back the new control register value. */ | ||
adds r0, #32 /* Discard everything up to r0. */ | ||
msr psp, r0 /* This is now the new top of stack to use in the task. */ | ||
isb | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/* | ||
* FreeRTOS Kernel <DEVELOPMENT BRANCH> | ||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* Copyright 2024 Arm Limited and/or its affiliates | ||
* <[email protected]> | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
|
@@ -165,8 +167,9 @@ vRestoreContextOfFirstTask: | |
|
||
ldm r0!, {r1-r2} /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ | ||
msr psplim, r1 /* Set this task's PSPLIM value. */ | ||
movs r1, #2 /* r1 = 2. */ | ||
msr CONTROL, r1 /* Switch to use PSP in the thread mode. */ | ||
mrs r3, control /* Obtain current control register value. */ | ||
orrs r3, r3, #2 /* r3 = r3 | 0x2 */ | ||
msr control, r3 /* Write back the new control register value. */ | ||
adds r0, #32 /* Discard everything up to r0. */ | ||
msr psp, r0 /* This is now the new top of stack to use in the task. */ | ||
isb | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/* | ||
* FreeRTOS Kernel <DEVELOPMENT BRANCH> | ||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* Copyright 2024 Arm Limited and/or its affiliates | ||
* <[email protected]> | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
|
@@ -165,8 +167,9 @@ vRestoreContextOfFirstTask: | |
|
||
ldm r0!, {r1-r2} /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ | ||
msr psplim, r1 /* Set this task's PSPLIM value. */ | ||
movs r1, #2 /* r1 = 2. */ | ||
msr CONTROL, r1 /* Switch to use PSP in the thread mode. */ | ||
mrs r3, control /* Obtain current control register value. */ | ||
orrs r3, r3, #2 /* r3 = r3 | 0x2 */ | ||
msr control, r3 /* Write back the new control register value. */ | ||
adds r0, #32 /* Discard everything up to r0. */ | ||
msr psp, r0 /* This is now the new top of stack to use in the task. */ | ||
isb | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/* | ||
* FreeRTOS Kernel <DEVELOPMENT BRANCH> | ||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* Copyright 2024 Arm Limited and/or its affiliates | ||
* <[email protected]> | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
|
@@ -165,8 +167,9 @@ vRestoreContextOfFirstTask: | |
|
||
ldm r0!, {r1-r2} /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */ | ||
msr psplim, r1 /* Set this task's PSPLIM value. */ | ||
movs r1, #2 /* r1 = 2. */ | ||
msr CONTROL, r1 /* Switch to use PSP in the thread mode. */ | ||
mrs r3, control /* Obtain current control register value. */ | ||
orrs r3, r3, #2 /* r3 = r3 | 0x2 */ | ||
msr control, r3 /* Write back the new control register value. */ | ||
adds r0, #32 /* Discard everything up to r0. */ | ||
msr psp, r0 /* This is now the new top of stack to use in the task. */ | ||
isb | ||
|