Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 1 | /* |
Ambroise Vincent | fae7772 | 2019-03-07 10:17:15 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2019, Arm Limited. All rights reserved. |
Varun Wadekar | 8900d8c | 2020-07-10 15:45:39 -0700 | [diff] [blame] | 3 | * Copyright (c) 2020, NVIDIA Corporation. All rights reserved. |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 4 | * |
| 5 | * SPDX-License-Identifier: BSD-3-Clause |
| 6 | */ |
| 7 | |
Arunachalam Ganapathy | 92f1868 | 2023-09-02 01:41:28 +0100 | [diff] [blame] | 8 | #include <arch_features.h> |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 9 | #include <arch_helpers.h> |
| 10 | |
| 11 | void tftf_arch_setup(void) |
| 12 | { |
| 13 | /* Do not try to configure EL2 if TFTF is running at NS-EL1 */ |
| 14 | if (IS_IN_EL2()) { |
Varun Wadekar | 8900d8c | 2020-07-10 15:45:39 -0700 | [diff] [blame] | 15 | /* Enable asynchronous SError aborts to EL2 */ |
| 16 | enable_serror(); |
| 17 | |
Sandrine Bailleux | dddec6b | 2018-12-18 15:45:01 +0100 | [diff] [blame] | 18 | /* |
| 19 | * Route physical interrupts to EL2 regardless of the value of |
| 20 | * the IMO/FMO bits. Without this, interrupts would not be taken |
| 21 | * and would remain pending, regardless of the PSTATE.{A, I, F} |
| 22 | * interrupt masks. |
| 23 | */ |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 24 | write_hcr_el2(HCR_TGE_BIT); |
Ambroise Vincent | fae7772 | 2019-03-07 10:17:15 +0000 | [diff] [blame] | 25 | |
| 26 | /* |
Arunachalam Ganapathy | 92f1868 | 2023-09-02 01:41:28 +0100 | [diff] [blame] | 27 | * Disable trap of SVE, SME instructions to EL2. |
Ambroise Vincent | fae7772 | 2019-03-07 10:17:15 +0000 | [diff] [blame] | 28 | * The fields of the CPTR_EL2 register reset to an |
| 29 | * architecturally UNKNOWN value. |
| 30 | */ |
Arunachalam Ganapathy | 92f1868 | 2023-09-02 01:41:28 +0100 | [diff] [blame] | 31 | write_cptr_el2(CPTR_EL2_RESET_VAL); |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 32 | isb(); |
Arunachalam Ganapathy | 92f1868 | 2023-09-02 01:41:28 +0100 | [diff] [blame] | 33 | |
| 34 | /* |
| 35 | * Enable access to ZT0 storage when FEAT_SME2 is implemented |
| 36 | * and enable FA64 when FEAT_SME_FA64 is implemented |
| 37 | */ |
| 38 | if (is_feat_sme_supported()) { |
| 39 | write_smcr_el2(SMCR_EL2_RESET_VAL); |
| 40 | isb(); |
| 41 | } |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 42 | } |
| 43 | } |