2 * Copyright (c) 2022 Arm Limited. All rights reserved.
4 * SPDX-License-Identifier: Apache-2.0
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 * CMSIS-Core(M) PAC key functions for Armv8.1-M PAC extension
26 #if defined ( __ICCARM__ )
27 #pragma system_include /* treat file as system include file for MISRA check */
28 #elif defined (__clang__)
29 #pragma clang system_header /* treat file as system include file */
32 /* ################### PAC Key functions ########################### */
34 \ingroup CMSIS_Core_FunctionInterface
35 \defgroup CMSIS_Core_PacKeyFunctions PAC Key functions
36 \brief Functions that access the PAC keys.
40 #if (defined (__ARM_FEATURE_PAUTH) && (__ARM_FEATURE_PAUTH == 1))
43 \brief read the PAC key used for privileged mode
44 \details Reads the PAC key stored in the PAC_KEY_P registers.
45 \param [out] pPacKey 128bit PAC key
47 __STATIC_FORCEINLINE void __get_PAC_KEY_P (uint32_t* pPacKey) {
49 "mrs r1, pac_key_p_0\n"
51 "mrs r1, pac_key_p_1\n"
53 "mrs r1, pac_key_p_2\n"
55 "mrs r1, pac_key_p_3\n"
57 : : "r" (pPacKey) : "memory", "r1"
62 \brief write the PAC key used for privileged mode
63 \details writes the given PAC key to the PAC_KEY_P registers.
64 \param [in] pPacKey 128bit PAC key
66 __STATIC_FORCEINLINE void __set_PAC_KEY_P (uint32_t* pPacKey) {
69 "msr pac_key_p_0, r1\n"
71 "msr pac_key_p_1, r1\n"
73 "msr pac_key_p_2, r1\n"
75 "msr pac_key_p_3, r1\n"
76 : : "r" (pPacKey) : "memory", "r1"
81 \brief read the PAC key used for unprivileged mode
82 \details Reads the PAC key stored in the PAC_KEY_U registers.
83 \param [out] pPacKey 128bit PAC key
85 __STATIC_FORCEINLINE void __get_PAC_KEY_U (uint32_t* pPacKey) {
87 "mrs r1, pac_key_u_0\n"
89 "mrs r1, pac_key_u_1\n"
91 "mrs r1, pac_key_u_2\n"
93 "mrs r1, pac_key_u_3\n"
95 : : "r" (pPacKey) : "memory", "r1"
100 \brief write the PAC key used for unprivileged mode
101 \details writes the given PAC key to the PAC_KEY_U registers.
102 \param [in] pPacKey 128bit PAC key
104 __STATIC_FORCEINLINE void __set_PAC_KEY_U (uint32_t* pPacKey) {
107 "msr pac_key_u_0, r1\n"
109 "msr pac_key_u_1, r1\n"
111 "msr pac_key_u_2, r1\n"
113 "msr pac_key_u_3, r1\n"
114 : : "r" (pPacKey) : "memory", "r1"
118 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
121 \brief read the PAC key used for privileged mode (non-secure)
122 \details Reads the PAC key stored in the non-secure PAC_KEY_P registers when in secure mode.
123 \param [out] pPacKey 128bit PAC key
125 __STATIC_FORCEINLINE void __TZ_get_PAC_KEY_P_NS (uint32_t* pPacKey) {
127 "mrs r1, pac_key_p_0_ns\n"
129 "mrs r1, pac_key_p_1_ns\n"
131 "mrs r1, pac_key_p_2_ns\n"
133 "mrs r1, pac_key_p_3_ns\n"
135 : : "r" (pPacKey) : "memory", "r1"
140 \brief write the PAC key used for privileged mode (non-secure)
141 \details writes the given PAC key to the non-secure PAC_KEY_P registers when in secure mode.
142 \param [in] pPacKey 128bit PAC key
144 __STATIC_FORCEINLINE void __TZ_set_PAC_KEY_P_NS (uint32_t* pPacKey) {
147 "msr pac_key_p_0_ns, r1\n"
149 "msr pac_key_p_1_ns, r1\n"
151 "msr pac_key_p_2_ns, r1\n"
153 "msr pac_key_p_3_ns, r1\n"
154 : : "r" (pPacKey) : "memory", "r1"
159 \brief read the PAC key used for unprivileged mode (non-secure)
160 \details Reads the PAC key stored in the non-secure PAC_KEY_U registers when in secure mode.
161 \param [out] pPacKey 128bit PAC key
163 __STATIC_FORCEINLINE void __TZ_get_PAC_KEY_U_NS (uint32_t* pPacKey) {
165 "mrs r1, pac_key_u_0_ns\n"
167 "mrs r1, pac_key_u_1_ns\n"
169 "mrs r1, pac_key_u_2_ns\n"
171 "mrs r1, pac_key_u_3_ns\n"
173 : : "r" (pPacKey) : "memory", "r1"
178 \brief write the PAC key used for unprivileged mode (non-secure)
179 \details writes the given PAC key to the non-secure PAC_KEY_U registers when in secure mode.
180 \param [in] pPacKey 128bit PAC key
182 __STATIC_FORCEINLINE void __TZ_set_PAC_KEY_U_NS (uint32_t* pPacKey) {
185 "msr pac_key_u_0_ns, r1\n"
187 "msr pac_key_u_1_ns, r1\n"
189 "msr pac_key_u_2_ns, r1\n"
191 "msr pac_key_u_3_ns, r1\n"
192 : : "r" (pPacKey) : "memory", "r1"
196 #endif /* (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) */
198 #endif /* (defined (__ARM_FEATURE_PAUTH) && (__ARM_FEATURE_PAUTH == 1)) */
200 /*@} end of CMSIS_Core_PacKeyFunctions */
203 #endif /* PAC_ARMV81_H */