aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadhukar Pappireddy <madhukar.pappireddy@arm.com>2022-06-22 17:47:38 -0500
committerMadhukar Pappireddy <madhukar.pappireddy@arm.com>2022-09-30 14:22:27 -0500
commit51b7f856fab4c54a7557cc11678143cdc7301e4a (patch)
treeb383d49b41ba9ffef21aaf027037ccb466defec2
parentfb6804c59d16b668ed2b9f3681d95c5b044dd8ec (diff)
downloadtf-a-tests-51b7f856fab4c54a7557cc11678143cdc7301e4a.tar.gz
test(interrupts): exercise managed exit by two SPs in a call chain
This patch adds a test to exercise the following scenario: NWd(tftf) sends a direct message request to the first SP which then extends the call chain by sending direct message request to the second SP. While the second SP is processing the direct message, a non-secure interrupt gets triggered. Both SPs support managed exit and send managed exit responses up the call chain. Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com> Change-Id: I9c07ff8964b18b63111eebc6233c9d652ec465ad
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_interrupts.c124
-rw-r--r--tftf/tests/tests-spm.xml2
2 files changed, 126 insertions, 0 deletions
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_interrupts.c b/tftf/tests/runtime_services/secure_service/test_ffa_interrupts.c
index 49c990393..248fb39a2 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_interrupts.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_interrupts.c
@@ -18,6 +18,7 @@ static volatile int timer_irq_received;
#define RECEIVER_3 SP_ID(3)
#define TIMER_DURATION 50U
#define SLEEP_TIME 100U
+#define SLEEP_TIME_FWD 200U
static const struct ffa_uuid expected_sp_uuids[] = {
{PRIMARY_UUID}, {SECONDARY_UUID}, {TERTIARY_UUID}
@@ -245,6 +246,129 @@ test_result_t test_ffa_ns_interrupt_signaled(void)
}
/*
+ * @Test_Aim@ This test exercises the following scenario: Managed exit is
+ * supported by both SPs in a call chain. A non-secure interrupt triggers
+ * while the second SP is processing a direct request message sent by the first
+ * SP. We choose SP(1) as the first SP and SP(3) as the second SP.
+ *
+ * 1. Enable managed exit interrupt by sending interrupt_enable command to both
+ * the Cactus SPs.
+ *
+ * 2. Register a handler for the non-secure timer interrupt. Program it to fire
+ * in a certain time.
+ *
+ * 3. Send a direct request to the first SP(i.e., SP(1)) to forward sleep command to
+ * the second SP(i.e., SP(3)).
+ *
+ * 4. While the second SP is running the busy loop, non-secure interrupt would
+ * trigger during this time.
+ *
+ * 5. The interrupt will be trapped to SPMC as FIQ. SPMC will inject the managed
+ * exit signal to the second SP through vIRQ conduit and perform eret to
+ * resume execution in the second SP.
+ *
+ * 6. The second SP sends the managed exit direct response to the first SP
+ * through its interrupt handler for managed exit.
+ *
+ * 7. SPMC proactively injects managed exit signal to the first SP through vFIQ
+ * conduit and resumes it using eret.
+ *
+ * 8. The first Cactus SP sends the managed exit direct response to TFTF through
+ * its interrupt handler for managed exit.
+ *
+ * 9. TFTF checks the return value in the direct message response from the first SP
+ * and ensures it is managed signal interrupt ID.
+ *
+ * 10. Check whether the pending non-secure timer interrupt successfully got
+ * handled in the normal world by TFTF.
+ *
+ * 11. Send a dummy direct message request command to resume the first SP's execution.
+ *
+ * 12. The first SP direct message request returns with managed exit response. It
+ * then sends a dummy direct message request command to resume the second SP's
+ * execution.
+ *
+ * 13. The second SP resumes in the sleep routine and sends a direct message
+ * response to the first SP.
+ *
+ * 14. The first SP checks if time lapsed is not lesser than sleep time and if
+ * successful, sends direct message response to the TFTF.
+ *
+ * 15. TFTF ensures the direct message response did not return with an error.
+ *
+ * 16. TFTF further disables the managed exit virtual interrupt for both the
+ * Cactus SPs.
+ *
+ */
+test_result_t test_ffa_ns_interrupt_managed_exit_chained(void)
+{
+ int ret;
+ struct ffa_value ret_values;
+
+ CHECK_SPMC_TESTING_SETUP(1, 1, expected_sp_uuids);
+
+ /* Enable managed exit interrupt in the secure side. */
+ if (!spm_set_managed_exit_int(RECEIVER, true) ||
+ !spm_set_managed_exit_int(RECEIVER_3, true)) {
+ return TEST_RESULT_FAIL;
+ }
+
+ ret = program_timer(TIMER_DURATION);
+ if (ret < 0) {
+ ERROR("Failed to program timer (%d)\n", ret);
+ return TEST_RESULT_FAIL;
+ }
+
+ /*
+ * Send request to first Cactus SP to send request to another Cactus
+ * SP to sleep.
+ */
+ ret_values = cactus_fwd_sleep_cmd(SENDER, RECEIVER, RECEIVER_3,
+ SLEEP_TIME_FWD);
+
+ if (!is_ffa_direct_response(ret_values)) {
+ return TEST_RESULT_FAIL;
+ }
+
+ /*
+ * Managed exit interrupt occurs during this time, Cactus
+ * will respond with interrupt ID.
+ */
+ if (cactus_get_response(ret_values) != MANAGED_EXIT_INTERRUPT_ID) {
+ ERROR("Managed exit interrupt did not occur!\n");
+ return TEST_RESULT_FAIL;
+ }
+
+ if (check_timer_interrupt() == 0) {
+ ERROR("Timer interrupt hasn't actually been handled.\n");
+ return TEST_RESULT_FAIL;
+ }
+
+ /*
+ * Send a dummy direct message request to relinquish CPU cycles.
+ * This resumes Cactus in the sleep routine.
+ */
+ ret_values = ffa_msg_send_direct_req64(SENDER, RECEIVER,
+ 0, 0, 0, 0, 0);
+
+ if (!is_ffa_direct_response(ret_values)) {
+ return TEST_RESULT_FAIL;
+ }
+
+ if (cactus_get_response(ret_values) == CACTUS_ERROR) {
+ return TEST_RESULT_FAIL;
+ }
+
+ /* Disable Managed exit interrupt. */
+ if (!spm_set_managed_exit_int(RECEIVER, false) ||
+ !spm_set_managed_exit_int(RECEIVER_3, false)) {
+ return TEST_RESULT_FAIL;
+ }
+
+ return TEST_RESULT_SUCCESS;
+}
+
+/*
* @Test_Aim@ Test the scenario where a non-secure interrupt triggers while a
* Secure Partition,that specified action for NS interrupt as QUEUED, is
* executing.
diff --git a/tftf/tests/tests-spm.xml b/tftf/tests/tests-spm.xml
index b069a6530..78d9c8b44 100644
--- a/tftf/tests/tests-spm.xml
+++ b/tftf/tests/tests-spm.xml
@@ -112,6 +112,8 @@
<testcase name="Test SPx with NS Interrupt queued"
function="test_ffa_ns_interrupt_queued" />
-->
+ <testcase name="Test Managed Exit in SP call chain"
+ function="test_ffa_ns_interrupt_managed_exit_chained" />
<testcase name="Test Managed Exit"
function="test_ffa_ns_interrupt_managed_exit" />
<testcase name="Test NS interrupt Signalable"