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.
28 #if defined ( __ICCARM__ )
29 #pragma system_include /* treat file as system include file for MISRA check */
30 #elif defined (__clang__)
31 #pragma clang system_header /* treat file as system include file */
34 /* ################### PAC Key functions ########################### */
36 \ingroup CMSIS_Core_FunctionInterface
37 \defgroup CMSIS_Core_PacKeyFunctions PAC Key functions
38 \brief Functions that access the PAC keys.
42 #if (defined (__ARM_FEATURE_PAUTH) && (__ARM_FEATURE_PAUTH == 1))
45 \brief read the PAC key used for privileged mode
46 \details Reads the PAC key stored in the PAC_KEY_P registers.
47 \param [out] pPacKey 128bit PAC key
49 __STATIC_FORCEINLINE void __get_PAC_KEY_P (uint32_t* pPacKey) {
51 "mrs r1, pac_key_p_0\n"
53 "mrs r1, pac_key_p_1\n"
55 "mrs r1, pac_key_p_2\n"
57 "mrs r1, pac_key_p_3\n"
59 : : "r" (pPacKey) : "memory", "r1"
64 \brief write the PAC key used for privileged mode
65 \details writes the given PAC key to the PAC_KEY_P registers.
66 \param [in] pPacKey 128bit PAC key
68 __STATIC_FORCEINLINE void __set_PAC_KEY_P (uint32_t* pPacKey) {
71 "msr pac_key_p_0, r1\n"
73 "msr pac_key_p_1, r1\n"
75 "msr pac_key_p_2, r1\n"
77 "msr pac_key_p_3, r1\n"
78 : : "r" (pPacKey) : "memory", "r1"
83 \brief read the PAC key used for unprivileged mode
84 \details Reads the PAC key stored in the PAC_KEY_U registers.
85 \param [out] pPacKey 128bit PAC key
87 __STATIC_FORCEINLINE void __get_PAC_KEY_U (uint32_t* pPacKey) {
89 "mrs r1, pac_key_u_0\n"
91 "mrs r1, pac_key_u_1\n"
93 "mrs r1, pac_key_u_2\n"
95 "mrs r1, pac_key_u_3\n"
97 : : "r" (pPacKey) : "memory", "r1"
102 \brief write the PAC key used for unprivileged mode
103 \details writes the given PAC key to the PAC_KEY_U registers.
104 \param [in] pPacKey 128bit PAC key
106 __STATIC_FORCEINLINE void __set_PAC_KEY_U (uint32_t* pPacKey) {
109 "msr pac_key_u_0, r1\n"
111 "msr pac_key_u_1, r1\n"
113 "msr pac_key_u_2, r1\n"
115 "msr pac_key_u_3, r1\n"
116 : : "r" (pPacKey) : "memory", "r1"
120 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
123 \brief read the PAC key used for privileged mode (non-secure)
124 \details Reads the PAC key stored in the non-secure PAC_KEY_P registers when in secure mode.
125 \param [out] pPacKey 128bit PAC key
127 __STATIC_FORCEINLINE void __TZ_get_PAC_KEY_P_NS (uint32_t* pPacKey) {
129 "mrs r1, pac_key_p_0_ns\n"
131 "mrs r1, pac_key_p_1_ns\n"
133 "mrs r1, pac_key_p_2_ns\n"
135 "mrs r1, pac_key_p_3_ns\n"
137 : : "r" (pPacKey) : "memory", "r1"
142 \brief write the PAC key used for privileged mode (non-secure)
143 \details writes the given PAC key to the non-secure PAC_KEY_P registers when in secure mode.
144 \param [in] pPacKey 128bit PAC key
146 __STATIC_FORCEINLINE void __TZ_set_PAC_KEY_P_NS (uint32_t* pPacKey) {
149 "msr pac_key_p_0_ns, r1\n"
151 "msr pac_key_p_1_ns, r1\n"
153 "msr pac_key_p_2_ns, r1\n"
155 "msr pac_key_p_3_ns, r1\n"
156 : : "r" (pPacKey) : "memory", "r1"
161 \brief read the PAC key used for unprivileged mode (non-secure)
162 \details Reads the PAC key stored in the non-secure PAC_KEY_U registers when in secure mode.
163 \param [out] pPacKey 128bit PAC key
165 __STATIC_FORCEINLINE void __TZ_get_PAC_KEY_U_NS (uint32_t* pPacKey) {
167 "mrs r1, pac_key_u_0_ns\n"
169 "mrs r1, pac_key_u_1_ns\n"
171 "mrs r1, pac_key_u_2_ns\n"
173 "mrs r1, pac_key_u_3_ns\n"
175 : : "r" (pPacKey) : "memory", "r1"
180 \brief write the PAC key used for unprivileged mode (non-secure)
181 \details writes the given PAC key to the non-secure PAC_KEY_U registers when in secure mode.
182 \param [in] pPacKey 128bit PAC key
184 __STATIC_FORCEINLINE void __TZ_set_PAC_KEY_U_NS (uint32_t* pPacKey) {
187 "msr pac_key_u_0_ns, r1\n"
189 "msr pac_key_u_1_ns, r1\n"
191 "msr pac_key_u_2_ns, r1\n"
193 "msr pac_key_u_3_ns, r1\n"
194 : : "r" (pPacKey) : "memory", "r1"
198 #endif /* (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) */
200 #endif /* (defined (__ARM_FEATURE_PAUTH) && (__ARM_FEATURE_PAUTH == 1)) */
202 /*@} end of CMSIS_Core_PacKeyFunctions */
205 #endif /* PAC_ARMV81_H */