diff --git a/Makefile b/Makefile index c588931f9..5132701dc 100644 --- a/Makefile +++ b/Makefile @@ -395,6 +395,13 @@ ifeq ($(RAS_EXTENSION),1) endif endif +# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled +ifeq ($(FAULT_INJECTION_SUPPORT),1) + ifneq ($(RAS_EXTENSION),1) + $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1) + endif +endif + ################################################################################ # Process platform overrideable behaviour ################################################################################ @@ -522,6 +529,7 @@ $(eval $(call assert_boolean,ENABLE_SPE_FOR_LOWER_ELS)) $(eval $(call assert_boolean,ENABLE_SPM)) $(eval $(call assert_boolean,ENABLE_SVE_FOR_NS)) $(eval $(call assert_boolean,ERROR_DEPRECATED)) +$(eval $(call assert_boolean,FAULT_INJECTION_SUPPORT)) $(eval $(call assert_boolean,GENERATE_COT)) $(eval $(call assert_boolean,GICV2_G0_FOR_EL3)) $(eval $(call assert_boolean,HANDLE_EA_EL3_FIRST)) @@ -571,6 +579,7 @@ $(eval $(call add_define,ENABLE_SPE_FOR_LOWER_ELS)) $(eval $(call add_define,ENABLE_SPM)) $(eval $(call add_define,ENABLE_SVE_FOR_NS)) $(eval $(call add_define,ERROR_DEPRECATED)) +$(eval $(call add_define,FAULT_INJECTION_SUPPORT)) $(eval $(call add_define,GICV2_G0_FOR_EL3)) $(eval $(call add_define,HANDLE_EA_EL3_FIRST)) $(eval $(call add_define,HW_ASSISTED_COHERENCY)) diff --git a/docs/user-guide.rst b/docs/user-guide.rst index 880fe7d9b..a1719ef25 100644 --- a/docs/user-guide.rst +++ b/docs/user-guide.rst @@ -390,6 +390,14 @@ Common build options handled at EL3, and a panic will result. This is supported only for AArch64 builds. +- ``FAULT_INJECTION_SUPPORT``: ARMv8.4 externsions introduced support for fault + injection from lower ELs, and this build option enables lower ELs to use + Error Records accessed via System Registers to inject faults. This is + applicable only to AArch64 builds. + + This feature is intended for testing purposes only, and is advisable to keep + disabled for production images. + - ``FIP_NAME``: This is an optional build option which specifies the FIP filename for the ``fip`` target. Default is ``fip.bin``. diff --git a/include/lib/aarch64/arch.h b/include/lib/aarch64/arch.h index e836db1e9..92bb97d51 100644 --- a/include/lib/aarch64/arch.h +++ b/include/lib/aarch64/arch.h @@ -215,6 +215,7 @@ /* SCR definitions */ #define SCR_RES1_BITS ((U(1) << 4) | (U(1) << 5)) +#define SCR_FIEN_BIT (U(1) << 21) #define SCR_TWE_BIT (U(1) << 13) #define SCR_TWI_BIT (U(1) << 12) #define SCR_ST_BIT (U(1) << 11) diff --git a/lib/el3_runtime/aarch64/context_mgmt.c b/lib/el3_runtime/aarch64/context_mgmt.c index 2608d1fcc..76eecc188 100644 --- a/lib/el3_runtime/aarch64/context_mgmt.c +++ b/lib/el3_runtime/aarch64/context_mgmt.c @@ -114,6 +114,11 @@ static void cm_init_context_common(cpu_context_t *ctx, const entry_point_info_t scr_el3 &= ~SCR_EA_BIT; #endif +#if FAULT_INJECTION_SUPPORT + /* Enable fault injection from lower ELs */ + scr_el3 |= SCR_FIEN_BIT; +#endif + #ifdef IMAGE_BL31 /* * SCR_EL3.IRQ, SCR_EL3.FIQ: Enable the physical FIQ and IRQ rounting as diff --git a/make_helpers/defaults.mk b/make_helpers/defaults.mk index 791a9c086..4bbff0345 100644 --- a/make_helpers/defaults.mk +++ b/make_helpers/defaults.mk @@ -76,6 +76,9 @@ EL3_EXCEPTION_HANDLING := 0 # Build flag to treat usage of deprecated platform and framework APIs as error. ERROR_DEPRECATED := 0 +# Fault injection support +FAULT_INJECTION_SUPPORT := 0 + # Byte alignment that each component in FIP is aligned to FIP_ALIGN := 0