blob: 7e6bc3d155a343c9ad510dd2b1deb7ec0c05ee19 [file] [log] [blame]
Gary Morrison3d7f6542021-01-27 13:08:47 -06001/*
2 * Copyright (c) 2021, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <lib/el3_runtime/cpu_data.h>
10
11 .global pauth_init_enable_el2
12 .global pauth_disable_el2
13
14/* -------------------------------------------------------------
15 * File contains EL2 versions of EL3 funcs in:
16 * .../lib/extensions/pauth/pauth_helpers.S
17 * -------------------------------------------------------------
18 */
19
20/* -------------------------------------------------------------
21 * Program APIAKey_EL1 and enable pointer authentication in EL2
22 * -------------------------------------------------------------
23 */
24func pauth_init_enable_el2
25 stp x29, x30, [sp, #-16]!
26
27 /* Initialize platform key */
28 bl plat_init_apkey
29
30 /* Program instruction key A used by the Trusted Firmware */
31 msr APIAKeyLo_EL1, x0
32 msr APIAKeyHi_EL1, x1
33
34 /* Enable pointer authentication */
35 mrs x0, sctlr_el2
36 orr x0, x0, #SCTLR_EnIA_BIT
37
38#if ENABLE_BTI
39 /* Enable PAC branch type compatibility */
40 bic x0, x0, #SCTLR_BT_BIT
41#endif
42 msr sctlr_el2, x0
43 isb
44
45 ldp x29, x30, [sp], #16
46 ret
47endfunc pauth_init_enable_el2
48
49/* -------------------------------------------------------------
50 * Disable pointer authentication in EL2
51 * -------------------------------------------------------------
52 */
53func pauth_disable_el2
54 mrs x0, sctlr_el2
55 bic x0, x0, #SCTLR_EnIA_BIT
56 msr sctlr_el2, x0
57 isb
58 ret
59endfunc pauth_disable_el2