Alexei Fedorov | 719714f | 2019-10-03 10:57:53 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2019, 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 | |
| 10 | .global pauth_init_enable |
| 11 | |
| 12 | /* ----------------------------------------------------------- |
| 13 | * Program APIAKey_EL1 key and enable Pointer Authentication |
| 14 | * of instruction addresses in the current translation regime |
| 15 | * for the calling CPU. |
| 16 | * ----------------------------------------------------------- |
| 17 | */ |
| 18 | func pauth_init_enable |
| 19 | stp x29, x30, [sp, #-16]! |
| 20 | |
| 21 | /* Initialize platform key */ |
| 22 | bl init_apkey |
| 23 | |
| 24 | /* |
| 25 | * Program instruction key A used by |
| 26 | * the Trusted Firmware Test Framework |
| 27 | */ |
| 28 | msr APIAKeyLo_EL1, x0 |
| 29 | msr APIAKeyHi_EL1, x1 |
| 30 | |
| 31 | /* Detect Current Exception level */ |
| 32 | mrs x0, CurrentEL |
| 33 | cmp x0, #(MODE_EL1 << MODE_EL_SHIFT) |
| 34 | b.eq enable_el1 |
| 35 | |
| 36 | /* Enable EL2 pointer authentication */ |
| 37 | mrs x0, sctlr_el2 |
| 38 | orr x0, x0, #SCTLR_EnIA_BIT |
| 39 | msr sctlr_el2, x0 |
| 40 | b enable_exit |
| 41 | |
| 42 | /* Enable EL1 pointer authentication */ |
| 43 | enable_el1: |
| 44 | mrs x0, sctlr_el1 |
| 45 | orr x0, x0, #SCTLR_EnIA_BIT |
| 46 | msr sctlr_el1, x0 |
| 47 | |
| 48 | enable_exit: |
| 49 | isb |
| 50 | |
| 51 | ldp x29, x30, [sp], #16 |
| 52 | ret |
| 53 | endfunc pauth_init_enable |