1 /******************************************************************************
3 * @brief CMSIS PAC key functions for Armv8.1-M PAC extension
6 ******************************************************************************/
8 * Copyright (c) 2022 Arm Limited. All rights reserved.
10 * SPDX-License-Identifier: Apache-2.0
12 * Licensed under the Apache License, Version 2.0 (the License); you may
13 * not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
16 * www.apache.org/licenses/LICENSE-2.0
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
25 #if defined ( __ICCARM__ )
26 #pragma system_include /* treat file as system include file for MISRA check */
27 #elif defined (__clang__)
28 #pragma clang system_header /* treat file as system include file */
35 /* ################### PAC Key functions ########################### */
37 \ingroup CMSIS_Core_FunctionInterface
38 \defgroup CMSIS_Core_PacKeyFunctions PAC Key functions
39 \brief Functions that access the PAC keys.
43 #if (defined (__ARM_FEATURE_PAUTH) && (__ARM_FEATURE_PAUTH == 1))
46 \brief read the PAC key used for privileged mode
47 \details Reads the PAC key stored in the PAC_KEY_P registers.
48 \param [out] pPacKey 128bit PAC key
50 __STATIC_FORCEINLINE void __get_PAC_KEY_P (uint32_t* pPacKey) {
52 "mrs r1, pac_key_p_0\n"
54 "mrs r1, pac_key_p_1\n"
56 "mrs r1, pac_key_p_2\n"
58 "mrs r1, pac_key_p_3\n"
60 : : "r" (pPacKey) : "memory", "r1"
65 \brief write the PAC key used for privileged mode
66 \details writes the given PAC key to the PAC_KEY_P registers.
67 \param [in] pPacKey 128bit PAC key
69 __STATIC_FORCEINLINE void __set_PAC_KEY_P (uint32_t* pPacKey) {
72 "msr pac_key_p_0, r1\n"
74 "msr pac_key_p_1, r1\n"
76 "msr pac_key_p_2, r1\n"
78 "msr pac_key_p_3, r1\n"
79 : : "r" (pPacKey) : "memory", "r1"
84 \brief read the PAC key used for unprivileged mode
85 \details Reads the PAC key stored in the PAC_KEY_U registers.
86 \param [out] pPacKey 128bit PAC key
88 __STATIC_FORCEINLINE void __get_PAC_KEY_U (uint32_t* pPacKey) {
90 "mrs r1, pac_key_u_0\n"
92 "mrs r1, pac_key_u_1\n"
94 "mrs r1, pac_key_u_2\n"
96 "mrs r1, pac_key_u_3\n"
98 : : "r" (pPacKey) : "memory", "r1"
103 \brief write the PAC key used for unprivileged mode
104 \details writes the given PAC key to the PAC_KEY_U registers.
105 \param [in] pPacKey 128bit PAC key
107 __STATIC_FORCEINLINE void __set_PAC_KEY_U (uint32_t* pPacKey) {
110 "msr pac_key_u_0, r1\n"
112 "msr pac_key_u_1, r1\n"
114 "msr pac_key_u_2, r1\n"
116 "msr pac_key_u_3, r1\n"
117 : : "r" (pPacKey) : "memory", "r1"
121 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
124 \brief read the PAC key used for privileged mode (non-secure)
125 \details Reads the PAC key stored in the non-secure PAC_KEY_P registers when in secure mode.
126 \param [out] pPacKey 128bit PAC key
128 __STATIC_FORCEINLINE void __TZ_get_PAC_KEY_P_NS (uint32_t* pPacKey) {
130 "mrs r1, pac_key_p_0_ns\n"
132 "mrs r1, pac_key_p_1_ns\n"
134 "mrs r1, pac_key_p_2_ns\n"
136 "mrs r1, pac_key_p_3_ns\n"
138 : : "r" (pPacKey) : "memory", "r1"
143 \brief write the PAC key used for privileged mode (non-secure)
144 \details writes the given PAC key to the non-secure PAC_KEY_P registers when in secure mode.
145 \param [in] pPacKey 128bit PAC key
147 __STATIC_FORCEINLINE void __TZ_set_PAC_KEY_P_NS (uint32_t* pPacKey) {
150 "msr pac_key_p_0_ns, r1\n"
152 "msr pac_key_p_1_ns, r1\n"
154 "msr pac_key_p_2_ns, r1\n"
156 "msr pac_key_p_3_ns, r1\n"
157 : : "r" (pPacKey) : "memory", "r1"
162 \brief read the PAC key used for unprivileged mode (non-secure)
163 \details Reads the PAC key stored in the non-secure PAC_KEY_U registers when in secure mode.
164 \param [out] pPacKey 128bit PAC key
166 __STATIC_FORCEINLINE void __TZ_get_PAC_KEY_U_NS (uint32_t* pPacKey) {
168 "mrs r1, pac_key_u_0_ns\n"
170 "mrs r1, pac_key_u_1_ns\n"
172 "mrs r1, pac_key_u_2_ns\n"
174 "mrs r1, pac_key_u_3_ns\n"
176 : : "r" (pPacKey) : "memory", "r1"
181 \brief write the PAC key used for unprivileged mode (non-secure)
182 \details writes the given PAC key to the non-secure PAC_KEY_U registers when in secure mode.
183 \param [in] pPacKey 128bit PAC key
185 __STATIC_FORCEINLINE void __TZ_set_PAC_KEY_U_NS (uint32_t* pPacKey) {
188 "msr pac_key_u_0_ns, r1\n"
190 "msr pac_key_u_1_ns, r1\n"
192 "msr pac_key_u_2_ns, r1\n"
194 "msr pac_key_u_3_ns, r1\n"
195 : : "r" (pPacKey) : "memory", "r1"
199 #endif /* (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) */
201 #endif /* (defined (__ARM_FEATURE_PAUTH) && (__ARM_FEATURE_PAUTH == 1)) */
203 /*@} end of CMSIS_Core_PacKeyFunctions */
206 #endif /* PAC_ARMV81_H */