feat: add a simple test to generate a EL3 panic
Add a simple patch which would generate a el3 panic from bl31_main
Cleanup and use crash-report tf-a config for bl31_main panic scenario.
Change-Id: Id9870210f3aef0886cd82e7ae5e0e14e82167367
Signed-off-by: Govindraj Raja <govindraj.raja@arm.com>
diff --git a/expect-lava/bl31_boot.exp b/expect-lava/bl31_boot.exp
new file mode 100644
index 0000000..89616cb
--- /dev/null
+++ b/expect-lava/bl31_boot.exp
@@ -0,0 +1,9 @@
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+source $ci_root/expect-lava/trusted-firmware.inc
diff --git a/expect-lava/bl31_main_panic.exp b/expect-lava/bl31_main_panic.exp
new file mode 100644
index 0000000..37519eb
--- /dev/null
+++ b/expect-lava/bl31_main_panic.exp
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+expect_string+=('i;BACKTRACE: START: bl31_main')
+expect_string+=('i;BACKTRACE: END: bl31_main')
+expect_string+=('i;PANIC in EL3.')
+
+expect_string+=("i;x30")
+source $ci_root/expect-lava/exception_gp_regs.inc
+source $ci_root/expect-lava/exception_sys_regs.inc
diff --git a/expect/bl31_boot.exp b/expect/bl31_boot.exp
new file mode 100644
index 0000000..aee2077
--- /dev/null
+++ b/expect/bl31_boot.exp
@@ -0,0 +1,11 @@
+#
+# Copyright (c) 2023 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+source [file join [file dirname [info script]] handle-arguments.inc]
+
+source [file join [file dirname [info script]] trusted-firmware.inc]
diff --git a/expect/bl31_main_panic.exp b/expect/bl31_main_panic.exp
new file mode 100644
index 0000000..4b6a95d
--- /dev/null
+++ b/expect/bl31_main_panic.exp
@@ -0,0 +1,17 @@
+#
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Expect script for Trusted Firmware Test Framework
+#
+
+source [file join [file dirname [info script]] handle-arguments.inc]
+
+expect_string "BACKTRACE: START: bl31_main"
+expect_string "BACKTRACE: END: bl31_main"
+expect_string "PANIC in EL3."
+
+expect_string "x30"
+source [file join [file dirname [info script]] exception_gp_regs.inc]
+source [file join [file dirname [info script]] exception_sys_regs.inc]
diff --git a/group/tf-l2-boot-tests-misc/fvp-crash-report,fvp-default:fvp-tftf-fip.tftf-aemv8a.runtime_bl31_main_panic-debug b/group/tf-l2-boot-tests-misc/fvp-crash-report,fvp-default:fvp-tftf-fip.tftf-aemv8a.runtime_bl31_main_panic-debug
new file mode 100644
index 0000000..c473896
--- /dev/null
+++ b/group/tf-l2-boot-tests-misc/fvp-crash-report,fvp-default:fvp-tftf-fip.tftf-aemv8a.runtime_bl31_main_panic-debug
@@ -0,0 +1,6 @@
+#
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
diff --git a/patch/fault_inject/induce_bl31_main_panic.patch b/patch/fault_inject/induce_bl31_main_panic.patch
new file mode 100644
index 0000000..55fc417
--- /dev/null
+++ b/patch/fault_inject/induce_bl31_main_panic.patch
@@ -0,0 +1,13 @@
+diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c
+index e70eb5584..3fb1e14b3 100644
+--- a/bl31/bl31_main.c
++++ b/bl31/bl31_main.c
+@@ -196,6 +196,8 @@ void bl31_main(void)
+ * from BL31
+ */
+ bl31_plat_runtime_setup();
++
++ panic();
+ }
+
+ /*******************************************************************************
diff --git a/run_config/fvp-aemv8a.runtime_bl31_main_panic b/run_config/fvp-aemv8a.runtime_bl31_main_panic
new file mode 100644
index 0000000..ff324cd
--- /dev/null
+++ b/run_config/fvp-aemv8a.runtime_bl31_main_panic
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+pre_tf_build() {
+ # Apply fault injection patches
+ apply_tf_patch "fault_inject/induce_bl31_main_panic.patch"
+}
+
+generate_lava_job() {
+ local model="base-aemv8a"
+
+ uart="0" timeout="60" file="bl31_boot.exp" track_expect
+ uart="1" timeout="60" file="bl31_main_panic.exp" set_primary="1" track_expect
+
+ model="$model" gen_model_params
+ model="$model" gen_fvp_yaml
+}
diff --git a/tf_config/fvp-crash-report b/tf_config/fvp-crash-report
index a766f9c..f0ad520 100644
--- a/tf_config/fvp-crash-report
+++ b/tf_config/fvp-crash-report
@@ -1,8 +1,4 @@
CRASH_REPORTING=1
CROSS_COMPILE=aarch64-none-elf-
-EL3_EXCEPTION_HANDLING=1
ENABLE_BACKTRACE=1
-FAULT_INJECTION_SUPPORT=1
-HANDLE_EA_EL3_FIRST_NS=1
PLAT=fvp
-SDEI_SUPPORT=1