Merge "test: group0 interrupt triggers while VM/SP is running"
diff --git a/plat/arm/fvp/fvp_tests_to_skip.txt b/plat/arm/fvp/fvp_tests_to_skip.txt
index d52947d..1769cac 100644
--- a/plat/arm/fvp/fvp_tests_to_skip.txt
+++ b/plat/arm/fvp/fvp_tests_to_skip.txt
@@ -1,6 +1,8 @@
#
-# Copyright (c) 2020, Arm Limited. All rights reserved.
+# Copyright (c) 2020-2023, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
+# Disable Group0 secure interrupt tests as there is no source of EL3 interrupt
+FF-A Group0 interrupts
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_group0_interrupts.c b/tftf/tests/runtime_services/secure_service/test_ffa_group0_interrupts.c
new file mode 100644
index 0000000..9359edf
--- /dev/null
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_group0_interrupts.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2023, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <cactus_test_cmds.h>
+#include <ffa_endpoints.h>
+#include <platform.h>
+#include <test_helpers.h>
+
+#define SP_SLEEP_TIME 200U
+#define NS_TIME_SLEEP 200U
+
+#define SENDER HYP_ID
+#define RECEIVER SP_ID(1)
+
+static const struct ffa_uuid expected_sp_uuids[] = { {PRIMARY_UUID} };
+
+test_result_t test_ffa_group0_interrupt_sp_running(void)
+{
+ struct ffa_value ret_values;
+
+ CHECK_SPMC_TESTING_SETUP(1, 1, expected_sp_uuids);
+
+ /* Send request to first Cactus SP to sleep for 200ms.*/
+ ret_values = cactus_sleep_cmd(SENDER, RECEIVER, SP_SLEEP_TIME);
+
+ /*
+ * SBSA secure watchdog timer fires every 100ms. Hence a Group0 secure
+ * interrupt should trigger during this time.
+ */
+ if (!is_ffa_direct_response(ret_values)) {
+ ERROR("Expected a direct response for sleep command\n");
+ return TEST_RESULT_FAIL;
+ }
+
+ /* Make sure elapsed time not less than sleep time. */
+ if (cactus_get_response(ret_values) < SP_SLEEP_TIME) {
+ ERROR("Lapsed time less than requested sleep time\n");
+ return TEST_RESULT_FAIL;
+ }
+
+ return TEST_RESULT_SUCCESS;
+}
+
+test_result_t test_ffa_group0_interrupt_in_nwd(void)
+{
+ uint64_t time1;
+ volatile uint64_t time2, time_lapsed;
+ uint64_t timer_freq = read_cntfrq_el0();
+
+ time1 = syscounter_read();
+
+ /*
+ * Sleep for NS_TIME_SLEEP ms. This ensures SBSA secure wdog timer
+ * triggers during this time.
+ */
+ waitms(NS_TIME_SLEEP);
+ time2 = syscounter_read();
+
+ /* Lapsed time should be at least equal to sleep time. */
+ time_lapsed = ((time2 - time1) * 1000) / timer_freq;
+
+ if (time_lapsed < NS_TIME_SLEEP) {
+ ERROR("Time elapsed less than expected value: %llu vs %u\n",
+ time_lapsed, NS_TIME_SLEEP);
+ return TEST_RESULT_FAIL;
+ }
+
+ return TEST_RESULT_SUCCESS;
+}
diff --git a/tftf/tests/tests-spm.mk b/tftf/tests/tests-spm.mk
index fccddb4..737c4cb 100644
--- a/tftf/tests/tests-spm.mk
+++ b/tftf/tests/tests-spm.mk
@@ -20,6 +20,7 @@
test_ffa_notifications.c \
test_spm_smmu.c \
test_ffa_exceptions.c \
+ test_ffa_group0_interrupts.c \
)
ifeq (${ARCH},aarch64)
diff --git a/tftf/tests/tests-spm.xml b/tftf/tests/tests-spm.xml
index 6c701ce..6285a97 100644
--- a/tftf/tests/tests-spm.xml
+++ b/tftf/tests/tests-spm.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (c) 2018-2022, Arm Limited. All rights reserved.
+ Copyright (c) 2018-2023, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
-->
@@ -64,6 +64,14 @@
</testsuite>
+ <testsuite name="FF-A Group0 interrupts"
+ description="Test FF-A Group0 secure interrupt delegation to EL3" >
+ <testcase name="FF-A Group0 secure world"
+ function="test_ffa_group0_interrupt_sp_running" />
+ <testcase name="FF-A Group0 normal world"
+ function="test_ffa_group0_interrupt_in_nwd" />
+ </testsuite>
+
<testsuite name="FF-A Power management"
description="Test FF-A power management" >
<testcase name="FF-A SP hotplug"