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