test: FFA_MSG_SEND_DIRECT_RESP2 intercepted

This test helps to validate the functionality of the SPMC to intercept a
direct response sent via FFA_MSG_SEND_DIRECT_RESP2 if there are pending
virtual secure interrupts and reschedule the partition to handle the
pending interrupt.

Upgrade `SP Service Second EL0` partition in ffa_secure_partitions test
setup to FF-A v1.2 to be able to receive direct messages sent via
FFA_MSG_SEND_DIRECT_REQ2. Also enable recv/send messaging methods for
FFA_MSG_SEND_DIRECT_REQ2 for this partition and for `SP Service Second
EL1` partition.

Signed-off-by: Kathleen Capella <kathleen.capella@arm.com>
Change-Id: I8def860eb14e35e01b964aa0d751e37efefbb18c
diff --git a/test/vmapi/ffa_secure_partitions/secure_interrupts.c b/test/vmapi/ffa_secure_partitions/secure_interrupts.c
index 51e6c52..50d06da 100644
--- a/test/vmapi/ffa_secure_partitions/secure_interrupts.c
+++ b/test/vmapi/ffa_secure_partitions/secure_interrupts.c
@@ -128,12 +128,12 @@
 	check_and_disable_trusted_wdog_timer(own_id, receiver_id);
 }
 
-/*
+/**
  * Test secure interrupt handling while the Secure Partition runs with
  * interrupts potentially masked. This test helps to validate the functionality
- * of the SPMC to intercept a direct response message if there are pending
- * virtual secure interrupts and reschedule the partition to handle the pending
- * interrupt.
+ * of the SPMC to intercept a direct response message sent via
+ * FFA_MSG_SEND_DIRECT_RESP_32 if there are pending virtual secure interrupts
+ * and reschedule the partition to handle the pending interrupt.
  */
 TEST(secure_interrupts, sp_direct_response_intercepted)
 {
@@ -162,6 +162,43 @@
 	check_and_disable_trusted_wdog_timer(own_id, receiver_id);
 }
 
+/**
+ * Test secure interrupt handling while the Secure Partition runs with
+ * interrupts potentially masked. This test helps to validate the functionality
+ * of the SPMC to intercept a direct response message sent via
+ * FFA_MSG_SEND_DIRECT_RESP2_64 if there are pending virtual secure interrupts
+ * and reschedule the partition to handle the pending interrupt.
+ */
+TEST(secure_interrupts, sp_direct_response2_intercepted)
+{
+	struct ffa_value res;
+	ffa_id_t own_id = hf_vm_get_id();
+	struct mailbox_buffers mb = set_up_mailbox();
+	struct ffa_partition_info *service2_info = service2(mb.recv);
+	const ffa_id_t receiver_id = service2_info->vm_id;
+	const uint64_t msg[] = {SP_SLEEP_CMD, SP_SLEEP_TIME, 1};
+	struct ffa_uuid uuid;
+
+	enable_trigger_trusted_wdog_timer(own_id, receiver_id, 400);
+
+	/* Send request to the SP to sleep uninterrupted. */
+	ffa_uuid_init(0, 0, 0, 0, &uuid);
+	res = ffa_msg_send_direct_req2(own_id, receiver_id, &uuid,
+				       (const uint64_t *)&msg, ARRAY_SIZE(msg));
+
+	/*
+	 * Secure interrupt should trigger during this time, SP will handle the
+	 * trusted watchdog timer interrupt.
+	 */
+	EXPECT_EQ(res.func, FFA_MSG_SEND_DIRECT_RESP2_64);
+	EXPECT_EQ(sp_resp(res), SP_SUCCESS);
+
+	/* Make sure elapsed time not less than sleep time. */
+	EXPECT_GE(res.arg5, SP_SLEEP_TIME);
+
+	check_and_disable_trusted_wdog_timer(own_id, receiver_id);
+}
+
 /*
  * This test is an extension of the 'sp_direct_response_intercepted' test. It
  * creates a scenario where a direct response message between two Secure