|
1 | 1 | /*
|
2 | 2 | * Copyright (c) 2013-2014 Wind River Systems, Inc.
|
3 | 3 | * Copyright (c) 2021 Lexmark International, Inc.
|
4 |
| - * Copyright (c) 2023 Arm Limited |
| 4 | + * Copyright (c) 2023, 2025 Arm Limited and/or its affiliates <[email protected]> |
5 | 5 | *
|
6 | 6 | * SPDX-License-Identifier: Apache-2.0
|
7 | 7 | */
|
|
20 | 20 | #include <zephyr/sys/barrier.h>
|
21 | 21 | #include <stdbool.h>
|
22 | 22 | #include <cmsis_core.h>
|
| 23 | +#include <zephyr/random/random.h> |
23 | 24 |
|
24 | 25 | #if (MPU_GUARD_ALIGN_AND_SIZE_FLOAT > MPU_GUARD_ALIGN_AND_SIZE)
|
25 | 26 | #define FP_GUARD_EXTRA_SIZE (MPU_GUARD_ALIGN_AND_SIZE_FLOAT - MPU_GUARD_ALIGN_AND_SIZE)
|
@@ -121,6 +122,12 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, char *sta
|
121 | 122 | #if defined(CONFIG_USERSPACE)
|
122 | 123 | thread->arch.priv_stack_start = 0;
|
123 | 124 | #endif
|
| 125 | +#endif |
| 126 | +#ifdef CONFIG_ARM_PAC_PER_THREAD |
| 127 | + /* Generate PAC key and save it in thread context to be set later |
| 128 | + * when the thread is actually switched in |
| 129 | + */ |
| 130 | + sys_csrand_get(&thread->arch.pac_keys, sizeof(struct pac_keys)); |
124 | 131 | #endif
|
125 | 132 | /*
|
126 | 133 | * initial values in all other registers/thread entries are
|
@@ -541,6 +548,9 @@ void arch_switch_to_main_thread(struct k_thread *main_thread, char *stack_ptr,
|
541 | 548 | #endif
|
542 | 549 | #endif /* CONFIG_BUILTIN_STACK_GUARD */
|
543 | 550 |
|
| 551 | +#ifdef CONFIG_ARM_PAC_PER_THREAD |
| 552 | + __set_PAC_KEY_P((uint32_t *)&main_thread->arch.pac_keys); |
| 553 | +#endif |
544 | 554 | /*
|
545 | 555 | * Set PSP to the highest address of the main stack
|
546 | 556 | * before enabling interrupts and jumping to main.
|
|
0 commit comments