2 * Copyright (c) 2019, Arm Limited. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
8 #include <asm_macros.S>
9 #include <lib/el3_runtime/cpu_data.h>
11 .global pauth_init_enable_el1
12 .global pauth_disable_el1
13 .global pauth_init_enable_el3
14 .global pauth_disable_el3
15 .globl pauth_load_bl31_apiakey
17 /* -------------------------------------------------------------
18 * Program APIAKey_EL1 and enable pointer authentication in EL1
19 * -------------------------------------------------------------
21 func pauth_init_enable_el1
22 stp x29, x30, [sp, #-16]!
24 /* Initialize platform key */
27 /* Program instruction key A used by the Trusted Firmware */
31 /* Enable pointer authentication */
33 orr x0, x0, #SCTLR_EnIA_BIT
36 /* Enable PAC branch type compatibility */
37 bic x0, x0, #(SCTLR_BT0_BIT | SCTLR_BT1_BIT)
42 ldp x29, x30, [sp], #16
44 endfunc pauth_init_enable_el1
46 /* -------------------------------------------------------------
47 * Disable pointer authentication in EL3
48 * -------------------------------------------------------------
50 func pauth_disable_el1
52 bic x0, x0, #SCTLR_EnIA_BIT
56 endfunc pauth_disable_el1
58 /* -------------------------------------------------------------
59 * Program APIAKey_EL1 and enable pointer authentication in EL3
60 * -------------------------------------------------------------
62 func pauth_init_enable_el3
63 stp x29, x30, [sp, #-16]!
65 /* Initialize platform key */
68 /* Program instruction key A used by the Trusted Firmware */
72 /* Enable pointer authentication */
74 orr x0, x0, #SCTLR_EnIA_BIT
77 /* Enable PAC branch type compatibility */
78 bic x0, x0, #SCTLR_BT_BIT
83 ldp x29, x30, [sp], #16
85 endfunc pauth_init_enable_el3
87 /* -------------------------------------------------------------
88 * Disable pointer authentication in EL3
89 * -------------------------------------------------------------
91 func pauth_disable_el3
93 bic x0, x0, #SCTLR_EnIA_BIT
97 endfunc pauth_disable_el3
99 /* -------------------------------------------------------------
100 * The following function strictly follows the AArch64 PCS
101 * to use x9-x17 (temporary caller-saved registers) to load
102 * the APIAKey_EL1 used by the firmware.
103 * -------------------------------------------------------------
105 func pauth_load_bl31_apiakey
106 /* tpidr_el3 contains the address of cpu_data structure */
109 /* Load apiakey from cpu_data */
110 ldp x10, x11, [x9, #CPU_DATA_APIAKEY_OFFSET]
112 /* Program instruction key A */
113 msr APIAKeyLo_EL1, x10
114 msr APIAKeyHi_EL1, x11
117 endfunc pauth_load_bl31_apiakey