blob: dde02669e8b56fdaf4c43a37bb8c862b0b50ce8d [file] [log] [blame]
johpow0181865962022-01-28 17:06:20 -06001/*
Jayanth Dodderi Chidanand118b3352024-06-18 15:22:54 +01002 * Copyright (c) 2022-2024, Arm Limited. All rights reserved.
johpow0181865962022-01-28 17:06:20 -06003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
Jayanth Dodderi Chidanand69316752022-05-09 12:33:03 +01008#include <arch_features.h>
johpow0181865962022-01-28 17:06:20 -06009#include <arch_helpers.h>
Boyan Karatotev6468d4a2023-02-16 15:12:45 +000010#include <lib/extensions/brbe.h>
johpow0181865962022-01-28 17:06:20 -060011
Jayanth Dodderi Chidanand118b3352024-06-18 15:22:54 +010012void brbe_enable(cpu_context_t *ctx)
johpow0181865962022-01-28 17:06:20 -060013{
Jayanth Dodderi Chidanand118b3352024-06-18 15:22:54 +010014 el3_state_t *state = get_el3state_ctx(ctx);
15 u_register_t mdcr_el3_val = read_ctx_reg(state, CTX_MDCR_EL3);
johpow0181865962022-01-28 17:06:20 -060016
Andre Przywarac97c5512022-11-17 16:42:09 +000017 /*
18 * MDCR_EL3.SBRBE = 0b01
19 *
20 * Allows BRBE usage in non-secure world and prohibited in
21 * secure world.
22 */
Jayanth Dodderi Chidanand118b3352024-06-18 15:22:54 +010023 mdcr_el3_val &= ~(MDCR_SBRBE_MASK << MDCR_SBRBE_SHIFT);
24 mdcr_el3_val |= (0x1UL << MDCR_SBRBE_SHIFT);
25 write_ctx_reg(state, CTX_MDCR_EL3, mdcr_el3_val);
johpow0181865962022-01-28 17:06:20 -060026}