feat: add test to verify unused ns el2 configuration
This test verifies the TF-A config INIT_UNUSED_NS_EL2. This macro
gaurds the code which is required to do a minimum initialization of
NS-EL2 for the systems which directly jumps to NS-EL1 from EL3.
This test applies a patch which runs TFTF at NS-EL1.
Signed-off-by: Manish Pandey <manish.pandey2@arm.com>
Change-Id: Ibe7e44ebd45f7afa4c5f97de22b2281d3d27068e
diff --git a/group/tftf-l2-fvp/fvp-unused-el2,fvp-template:fvp-tftf-fip.tftf-unused_el2-aemva-debug b/group/tftf-l2-fvp/fvp-unused-el2,fvp-template:fvp-tftf-fip.tftf-unused_el2-aemva-debug
new file mode 100644
index 0000000..b452bbf
--- /dev/null
+++ b/group/tftf-l2-fvp/fvp-unused-el2,fvp-template:fvp-tftf-fip.tftf-unused_el2-aemva-debug
@@ -0,0 +1,5 @@
+#
+# Copyright (c) 2023 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
diff --git a/patch/unused_el2/run_tftf_at_el1 b/patch/unused_el2/run_tftf_at_el1
new file mode 100644
index 0000000..1108367
--- /dev/null
+++ b/patch/unused_el2/run_tftf_at_el1
@@ -0,0 +1,13 @@
+diff --git a/plat/arm/common/arm_common.c b/plat/arm/common/arm_common.c
+index fc681149e..4ef0070b5 100644
+--- a/plat/arm/common/arm_common.c
++++ b/plat/arm/common/arm_common.c
+@@ -90,7 +90,7 @@ uint32_t arm_get_spsr_for_bl33_entry(void)
+ uint32_t spsr;
+
+ /* Figure out what mode we enter the non-secure world in */
+- mode = (el_implemented(2) != EL_IMPL_NONE) ? MODE_EL2 : MODE_EL1;
++ mode = MODE_EL1;
+
+ /*
+ * TODO: Consider the possibility of specifying the SPSR in
diff --git a/run_config/fvp-unused_el2 b/run_config/fvp-unused_el2
new file mode 100644
index 0000000..f521913
--- /dev/null
+++ b/run_config/fvp-unused_el2
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+pre_tf_build() {
+ # Apply patch to run tftf at NS-EL1 exception level
+ apply_tf_patch "unused_el2/run_tftf_at_el1"
+}
diff --git a/tf_config/fvp-unused-el2 b/tf_config/fvp-unused-el2
new file mode 100644
index 0000000..e17cd0e
--- /dev/null
+++ b/tf_config/fvp-unused-el2
@@ -0,0 +1,3 @@
+CROSS_COMPILE=aarch64-none-elf-
+INIT_UNUSED_NS_EL2=1
+PLAT=fvp