diff options
author | Jayanth Dodderi Chidanand <jayanthdodderi.chidanand@arm.com> | 2022-03-28 15:28:55 +0100 |
---|---|---|
committer | Jayanth Dodderi Chidanand <jayanthdodderi.chidanand@arm.com> | 2022-04-17 23:48:10 +0100 |
commit | 781d07a421380cdaede14a9f5932d9aa5bff1903 (patch) | |
tree | 438344cb0c950e1dc96c6271f79d83766a8e2caf /lib | |
parent | 863296898a597775db3c760a4dcf8a02ca8805e2 (diff) | |
download | trusted-firmware-a-781d07a421380cdaede14a9f5932d9aa5bff1903.tar.gz |
refactor(twed): improve TWED enablement in EL-3
The current implementation uses plat_arm API under generic code.
"plat_arm" API is a convention used with Arm common platform layer
and is reserved for that purpose. In addition, the function has a
weak definition which is not encouraged in TF-A.
Henceforth, removing the weak API with a configurable macro "TWED_DELAY"
of numeric data type in generic code and simplifying the implementation.
By default "TWED_DELAY" is defined to zero, and the delay value need to
be explicitly set by the platforms during buildtime.
Signed-off-by: Jayanth Dodderi Chidanand <jayanthdodderi.chidanand@arm.com>
Change-Id: I25cd6f628e863dc40415ced3a82d0662fdf2d75a
Diffstat (limited to 'lib')
-rw-r--r-- | lib/el3_runtime/aarch64/context_mgmt.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/lib/el3_runtime/aarch64/context_mgmt.c b/lib/el3_runtime/aarch64/context_mgmt.c index 459ca2ce46..47e7d8c31a 100644 --- a/lib/el3_runtime/aarch64/context_mgmt.c +++ b/lib/el3_runtime/aarch64/context_mgmt.c @@ -27,11 +27,14 @@ #include <lib/extensions/sys_reg_trace.h> #include <lib/extensions/trbe.h> #include <lib/extensions/trf.h> -#include <lib/extensions/twed.h> #include <lib/utils.h> -static void manage_extensions_secure(cpu_context_t *ctx); +#if ENABLE_FEAT_TWED +/* Make sure delay value fits within the range(0-15) */ +CASSERT(((TWED_DELAY & ~SCR_TWEDEL_MASK) == 0U), assert_twed_delay_value_check); +#endif /* ENABLE_FEAT_TWED */ +static void manage_extensions_secure(cpu_context_t *ctx); /****************************************************************************** * This function performs initializations that are specific to SECURE state * and updates the cpu context specified by 'ctx'. @@ -329,23 +332,16 @@ static void setup_context_common(cpu_context_t *ctx, const entry_point_info_t *e sctlr_elx |= SCTLR_IESB_BIT; #endif +#if ENABLE_FEAT_TWED /* Enable WFE trap delay in SCR_EL3 if supported and configured */ - if (is_armv8_6_twed_present()) { - uint32_t delay = plat_arm_set_twedel_scr_el3(); - - if (delay != TWED_DISABLED) { - /* Make sure delay value fits */ - assert((delay & ~SCR_TWEDEL_MASK) == 0U); - - /* Set delay in SCR_EL3 */ - scr_el3 &= ~(SCR_TWEDEL_MASK << SCR_TWEDEL_SHIFT); - scr_el3 |= ((delay & SCR_TWEDEL_MASK) - << SCR_TWEDEL_SHIFT); - - /* Enable WFE delay */ - scr_el3 |= SCR_TWEDEn_BIT; - } - } + /* Set delay in SCR_EL3 */ + scr_el3 &= ~(SCR_TWEDEL_MASK << SCR_TWEDEL_SHIFT); + scr_el3 |= ((TWED_DELAY & SCR_TWEDEL_MASK) + << SCR_TWEDEL_SHIFT); + + /* Enable WFE delay */ + scr_el3 |= SCR_TWEDEn_BIT; +#endif /* ENABLE_FEAT_TWED */ /* * Store the initialised SCTLR_EL1 value in the cpu_context - SCTLR_EL2 |