johpow01 | 8186596 | 2022-01-28 17:06:20 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2022, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <arch_helpers.h> |
| 9 | |
| 10 | static bool brbe_supported(void) |
| 11 | { |
| 12 | uint64_t features; |
| 13 | |
| 14 | features = read_id_aa64dfr0_el1() >> ID_AA64DFR0_BRBE_SHIFT; |
| 15 | return ((features & ID_AA64DFR0_BRBE_MASK) == |
| 16 | ID_AA64DFR0_BRBE_SUPPORTED); |
| 17 | } |
| 18 | |
| 19 | void brbe_enable(void) |
| 20 | { |
| 21 | uint64_t val; |
| 22 | |
| 23 | if (brbe_supported()) { |
| 24 | /* |
| 25 | * MDCR_EL3.SBRBE = 0b01 |
| 26 | * |
| 27 | * Allows BRBE usage in non-secure world and prohibited in |
| 28 | * secure world. |
| 29 | */ |
| 30 | val = read_mdcr_el3(); |
| 31 | val &= ~(MDCR_SBRBE_MASK << MDCR_SBRBE_SHIFT); |
| 32 | val |= (0x1UL << MDCR_SBRBE_SHIFT); |
| 33 | write_mdcr_el3(val); |
| 34 | } |
| 35 | } |