diff options
author | Manish Pandey <manish.pandey2@arm.com> | 2023-01-19 18:19:50 +0100 |
---|---|---|
committer | TrustedFirmware Code Review <review@review.trustedfirmware.org> | 2023-01-19 18:19:50 +0100 |
commit | 344e5e8149f98fcbb2360cabc1dfc99db210ef82 (patch) | |
tree | ca911d4700d2e0604961aef4916f9734cd9ee446 /lib/el3_runtime | |
parent | 96df1f1db6e824cd3802dd7bcf245359e779cfcb (diff) | |
parent | 2e1241888ee82a5a9b3b30acd83a1f4ea6732f1b (diff) |
Merge changes from topic "feat_state_rework" into integration
* changes:
feat(fvp): enable FEAT_HCX by default
refactor(context-mgmt): move FEAT_HCX save/restore into C
refactor(cpufeat): convert FEAT_HCX to new scheme
feat(fvp): enable FEAT_FGT by default
refactor(context-mgmt): move FEAT_FGT save/restore code into C
refactor(amu): convert FEAT_AMUv1 to new scheme
refactor(cpufeat): decouple FGT feature detection and build flags
refactor(cpufeat): check FEAT_FGT in a new way
refactor(cpufeat): move helpers into .c file, rename FEAT_STATE_
feat(aarch64): make ID system register reads non-volatile
Diffstat (limited to 'lib/el3_runtime')
-rw-r--r-- | lib/el3_runtime/aarch64/context.S | 60 | ||||
-rw-r--r-- | lib/el3_runtime/aarch64/context_mgmt.c | 57 |
2 files changed, 43 insertions, 74 deletions
diff --git a/lib/el3_runtime/aarch64/context.S b/lib/el3_runtime/aarch64/context.S index aa0327b51..b5d61ff35 100644 --- a/lib/el3_runtime/aarch64/context.S +++ b/lib/el3_runtime/aarch64/context.S @@ -25,10 +25,6 @@ .global el2_sysregs_context_save_mpam .global el2_sysregs_context_restore_mpam #endif /* ENABLE_MPAM_FOR_LOWER_ELS */ -#if ENABLE_FEAT_FGT - .global el2_sysregs_context_save_fgt - .global el2_sysregs_context_restore_fgt -#endif /* ENABLE_FEAT_FGT */ #if ENABLE_FEAT_ECV .global el2_sysregs_context_save_ecv .global el2_sysregs_context_restore_ecv @@ -53,10 +49,6 @@ .global el2_sysregs_context_save_csv2 .global el2_sysregs_context_restore_csv2 #endif /* ENABLE_FEAT_CSV2_2 */ -#if ENABLE_FEAT_HCX - .global el2_sysregs_context_save_hcx - .global el2_sysregs_context_restore_hcx -#endif /* ENABLE_FEAT_HCX */ #endif /* CTX_INCLUDE_EL2_REGS */ .global el1_sysregs_context_save @@ -314,45 +306,6 @@ func el2_sysregs_context_restore_mpam endfunc el2_sysregs_context_restore_mpam #endif /* ENABLE_MPAM_FOR_LOWER_ELS */ -#if ENABLE_FEAT_FGT -func el2_sysregs_context_save_fgt - mrs x13, HDFGRTR_EL2 -#if ENABLE_FEAT_AMUv1 - mrs x14, HAFGRTR_EL2 - stp x13, x14, [x0, #CTX_HDFGRTR_EL2] -#else - str x13, [x0, #CTX_HDFGRTR_EL2] -#endif /* ENABLE_FEAT_AMUv1 */ - mrs x15, HDFGWTR_EL2 - mrs x16, HFGITR_EL2 - stp x15, x16, [x0, #CTX_HDFGWTR_EL2] - - mrs x9, HFGRTR_EL2 - mrs x10, HFGWTR_EL2 - stp x9, x10, [x0, #CTX_HFGRTR_EL2] - ret -endfunc el2_sysregs_context_save_fgt - -func el2_sysregs_context_restore_fgt - #if ENABLE_FEAT_AMUv1 - ldp x13, x14, [x0, #CTX_HDFGRTR_EL2] - msr HAFGRTR_EL2, x14 -#else - ldr x13, [x0, #CTX_HDFGRTR_EL2] -#endif /* ENABLE_FEAT_AMUv1 */ - msr HDFGRTR_EL2, x13 - - ldp x15, x16, [x0, #CTX_HDFGWTR_EL2] - msr HDFGWTR_EL2, x15 - msr HFGITR_EL2, x16 - - ldp x9, x10, [x0, #CTX_HFGRTR_EL2] - msr HFGRTR_EL2, x9 - msr HFGWTR_EL2, x10 - ret -endfunc el2_sysregs_context_restore_fgt -#endif /* ENABLE_FEAT_FGT */ - #if ENABLE_FEAT_ECV func el2_sysregs_context_save_ecv mrs x11, CNTPOFF_EL2 @@ -475,19 +428,6 @@ func el2_sysregs_context_restore_csv2 endfunc el2_sysregs_context_restore_csv2 #endif /* ENABLE_FEAT_CSV2_2 */ -#if ENABLE_FEAT_HCX -func el2_sysregs_context_save_hcx - mrs x14, hcrx_el2 - str x14, [x0, #CTX_HCRX_EL2] - ret -endfunc el2_sysregs_context_save_hcx - -func el2_sysregs_context_restore_hcx - ldr x14, [x0, #CTX_HCRX_EL2] - msr hcrx_el2, x14 - ret -endfunc el2_sysregs_context_restore_hcx -#endif /* ENABLE_FEAT_HCX */ #endif /* CTX_INCLUDE_EL2_REGS */ /* ------------------------------------------------------------------ diff --git a/lib/el3_runtime/aarch64/context_mgmt.c b/lib/el3_runtime/aarch64/context_mgmt.c index 866ac4154..3bcefdb5d 100644 --- a/lib/el3_runtime/aarch64/context_mgmt.c +++ b/lib/el3_runtime/aarch64/context_mgmt.c @@ -320,9 +320,9 @@ static void setup_context_common(cpu_context_t *ctx, const entry_point_info_t *e * If FEAT_HCX is enabled, enable access to HCRX_EL2 by setting * SCR_EL3.HXEn. */ -#if ENABLE_FEAT_HCX - scr_el3 |= SCR_HXEn_BIT; -#endif + if (is_feat_hcx_supported()) { + scr_el3 |= SCR_HXEn_BIT; + } /* * If FEAT_RNG_TRAP is enabled, all reads of the RNDR and RNDRRS @@ -359,7 +359,7 @@ static void setup_context_common(cpu_context_t *ctx, const entry_point_info_t *e && (GET_M32(ep->spsr) == MODE32_hyp))) { scr_el3 |= SCR_HCE_BIT; - if (is_armv8_6_fgt_present()) { + if (is_feat_fgt_supported()) { scr_el3 |= SCR_FGTEN_BIT; } @@ -792,6 +792,35 @@ void cm_prepare_el3_exit(uint32_t security_state) } #if CTX_INCLUDE_EL2_REGS + +static void el2_sysregs_context_save_fgt(el2_sysregs_t *ctx) +{ + if (is_feat_fgt_supported()) { + write_ctx_reg(ctx, CTX_HDFGRTR_EL2, read_hdfgrtr_el2()); + if (is_feat_amu_supported()) { + write_ctx_reg(ctx, CTX_HAFGRTR_EL2, read_hafgrtr_el2()); + } + write_ctx_reg(ctx, CTX_HDFGWTR_EL2, read_hdfgwtr_el2()); + write_ctx_reg(ctx, CTX_HFGITR_EL2, read_hfgitr_el2()); + write_ctx_reg(ctx, CTX_HFGRTR_EL2, read_hfgrtr_el2()); + write_ctx_reg(ctx, CTX_HFGWTR_EL2, read_hfgwtr_el2()); + } +} + +static void el2_sysregs_context_restore_fgt(el2_sysregs_t *ctx) +{ + if (is_feat_fgt_supported()) { + write_hdfgrtr_el2(read_ctx_reg(ctx, CTX_HDFGRTR_EL2)); + if (is_feat_amu_supported()) { + write_hafgrtr_el2(read_ctx_reg(ctx, CTX_HAFGRTR_EL2)); + } + write_hdfgwtr_el2(read_ctx_reg(ctx, CTX_HDFGWTR_EL2)); + write_hfgitr_el2(read_ctx_reg(ctx, CTX_HFGITR_EL2)); + write_hfgrtr_el2(read_ctx_reg(ctx, CTX_HFGRTR_EL2)); + write_hfgwtr_el2(read_ctx_reg(ctx, CTX_HFGWTR_EL2)); + } +} + /******************************************************************************* * Save EL2 sysreg context ******************************************************************************/ @@ -823,9 +852,9 @@ void cm_el2_sysregs_context_save(uint32_t security_state) #if ENABLE_MPAM_FOR_LOWER_ELS el2_sysregs_context_save_mpam(el2_sysregs_ctx); #endif -#if ENABLE_FEAT_FGT + el2_sysregs_context_save_fgt(el2_sysregs_ctx); -#endif + #if ENABLE_FEAT_ECV el2_sysregs_context_save_ecv(el2_sysregs_ctx); #endif @@ -844,9 +873,9 @@ void cm_el2_sysregs_context_save(uint32_t security_state) #if ENABLE_FEAT_CSV2_2 el2_sysregs_context_save_csv2(el2_sysregs_ctx); #endif -#if ENABLE_FEAT_HCX - el2_sysregs_context_save_hcx(el2_sysregs_ctx); -#endif + if (is_feat_hcx_supported()) { + write_ctx_reg(el2_sysregs_ctx, CTX_HCRX_EL2, read_hcrx_el2()); + } } } @@ -881,9 +910,9 @@ void cm_el2_sysregs_context_restore(uint32_t security_state) #if ENABLE_MPAM_FOR_LOWER_ELS el2_sysregs_context_restore_mpam(el2_sysregs_ctx); #endif -#if ENABLE_FEAT_FGT + el2_sysregs_context_restore_fgt(el2_sysregs_ctx); -#endif + #if ENABLE_FEAT_ECV el2_sysregs_context_restore_ecv(el2_sysregs_ctx); #endif @@ -902,9 +931,9 @@ void cm_el2_sysregs_context_restore(uint32_t security_state) #if ENABLE_FEAT_CSV2_2 el2_sysregs_context_restore_csv2(el2_sysregs_ctx); #endif -#if ENABLE_FEAT_HCX - el2_sysregs_context_restore_hcx(el2_sysregs_ctx); -#endif + if (is_feat_hcx_supported()) { + write_hcrx_el2(read_ctx_reg(el2_sysregs_ctx, CTX_HCRX_EL2)); + } } } #endif /* CTX_INCLUDE_EL2_REGS */ |