Merge changes from topic "ja/notifications"

* changes:
  test(notifications): signaling from MP SP to UP SP
  feat(cactus): enable notifications for cactus tertiary
  test(notification): support included in FFA_PARTITION_INFO_GET
  test(cactus): notifications support enabled in manifest
  test(notifications): retrieve interrupt IDs
  feat(notifications): update FFA_FEATURES test
  feat(spm): add VM_ID macro to spm tests
  test(notifications): NPI for per-vCPU notifications
  feat: spm helper functions for MP tests
  refactor(notifications): tidy global notifications to SP tests
  test(notifications): NPI handling
  feat(cactus): validate NPI injection
  test(notifications): validate SRI is delayed
  test(ff-a): notifications SRI is not delayed
  refactor(spm): managed exit tests
  refactor(cactus): notification set command for SRI test
  feat(cactus): count requests received
  test(notifications): test schedule receiver interrupt
  feat(tftf): improve notifications tests logging
diff --git a/include/lib/aarch32/arch_features.h b/include/lib/aarch32/arch_features.h
index b61e626..1addc44 100644
--- a/include/lib/aarch32/arch_features.h
+++ b/include/lib/aarch32/arch_features.h
@@ -48,4 +48,9 @@
 		ID_DFR0_COPTRC_MASK) ==
 		ID_DFR0_COPTRC_SUPPORTED;
 }
+
+static inline unsigned int get_armv9_2_feat_rme_support(void)
+{
+	return 0;
+}
 #endif /* ARCH_FEATURES_H */
diff --git a/include/runtime_services/realm_payload/realm_payload_test.h b/include/runtime_services/realm_payload/realm_payload_test.h
index eccdbb3..c31dd6a 100644
--- a/include/runtime_services/realm_payload/realm_payload_test.h
+++ b/include/runtime_services/realm_payload/realm_payload_test.h
@@ -26,7 +26,7 @@
 #define RMI_FNUM_VERSION_REQ		U(0)
 
 #define RMI_FNUM_GRAN_NS_REALM		U(1)
-#define RMI_FNUM_GRAN_REALM_NS		U(0x10)
+#define RMI_FNUM_GRAN_REALM_NS		U(2)
 
 /********************************************************************************/
 
diff --git a/tftf/tests/runtime_services/realm_payload/realm_payload_spm_test.c b/tftf/tests/runtime_services/realm_payload/realm_payload_spm_test.c
index e552ecb..a1e07e9 100644
--- a/tftf/tests/runtime_services/realm_payload/realm_payload_spm_test.c
+++ b/tftf/tests/runtime_services/realm_payload/realm_payload_spm_test.c
@@ -1,3 +1,9 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
 #include <stdlib.h>
 
 #include <debug.h>
@@ -15,7 +21,6 @@
 #include <plat_topology.h>
 #include <runtime_services/realm_payload/realm_payload_test.h>
 
-#ifdef __aarch64__
 static test_result_t realm_multi_cpu_payload_del_undel(void);
 
 #define ECHO_VAL1 U(0xa0a0a0a0)
@@ -29,7 +34,7 @@
 
 /*
  * The following test conducts SPM(direct messaging) tests on a subset of selected CPUs while
- * simultaneously performing another set of tests of the RMI(delelgation)
+ * simultaneously performing another set of tests of the RMI(delegation)
  * on the remaining CPU's to the full platform count. Once that test completes
  * the same test is run again with a different assignment for what CPU does
  * SPM versus RMI.
@@ -213,7 +218,6 @@
 
 	return ret;
 }
-#endif
 
 /*
  * Test function to dispatch a number of SPM and RMI tests to the platform
@@ -222,8 +226,6 @@
  */
 test_result_t test_ffa_secondary_core_direct_realm_msg(void)
 {
-	SKIP_TEST_IF_AARCH32();
-#ifdef __aarch64__
 	if (get_armv9_2_feat_rme_support() == 0U) {
 		return TEST_RESULT_SKIPPED;
 	}
@@ -231,6 +233,7 @@
 	unsigned int lead_mpid = read_mpidr_el1() & MPID_MASK;
 	unsigned int cpu_node, mpidr;
 	int32_t ret;
+	u_register_t retrmm;
 
 	/**********************************************************************
 	 * Check SPMC has ffa_version and expected FFA endpoints are deployed.
@@ -341,6 +344,18 @@
 
 	}
 
+	for (int i = 0; i < (NUM_GRANULES * PLATFORM_CORE_COUNT) ; i++) {
+		if (bufferstate[i] == B_DELEGATED) {
+			retrmm = realm_granule_undelegate(
+				(u_register_t)&bufferdelegate[i * GRANULE_SIZE]);
+			bufferstate[i] = B_UNDELEGATED;
+			if (retrmm != 0UL) {
+				tftf_testcase_printf("Delegate operation returns fail, %lx\n", retrmm);
+				return TEST_RESULT_FAIL;
+			}
+		}
+	}
+
 	VERBOSE("Done exiting.\n");
 
 	/**********************************************************************
@@ -348,10 +363,8 @@
 	 **********************************************************************/
 
 	return TEST_RESULT_SUCCESS;
-#endif
 }
 
-#ifdef __aarch64__
 /*
  * Multi CPU testing of delegate and undelegate of granules
  * The granules are first randomly initialized to either realm or non secure
@@ -369,11 +382,13 @@
 	for (int i = 0; i < NUM_GRANULES; i++) {
 		if (bufferstate[((cpu_node * NUM_GRANULES) + i)] == B_UNDELEGATED) {
 			retrmm = realm_granule_delegate((u_register_t)
-					&bufferdelegate[((cpu_node * NUM_GRANULES) + i) * GRANULE_SIZE]);
+					&bufferdelegate[((cpu_node *
+						NUM_GRANULES) + i) * GRANULE_SIZE]);
 			bufferstate[((cpu_node * NUM_GRANULES) + i)] = B_DELEGATED;
 		} else {
 			retrmm = realm_granule_undelegate((u_register_t)
-					&bufferdelegate[((cpu_node * NUM_GRANULES) + i) * GRANULE_SIZE]);
+					&bufferdelegate[((cpu_node *
+						NUM_GRANULES) + i) * GRANULE_SIZE]);
 			bufferstate[((cpu_node * NUM_GRANULES) + i)] = B_UNDELEGATED;
 		}
 		if (retrmm != 0UL) {
@@ -381,6 +396,6 @@
 			return TEST_RESULT_FAIL;
 		}
 	}
+
 	return TEST_RESULT_SUCCESS;
 }
-#endif
diff --git a/tftf/tests/runtime_services/realm_payload/realm_payload_test.c b/tftf/tests/runtime_services/realm_payload/realm_payload_test.c
index d1063f4..8bdc60a 100644
--- a/tftf/tests/runtime_services/realm_payload/realm_payload_test.c
+++ b/tftf/tests/runtime_services/realm_payload/realm_payload_test.c
@@ -13,14 +13,12 @@
 #include <runtime_services/realm_payload/realm_payload_test.h>
 #include <test_helpers.h>
 
-#ifdef __aarch64__
 static test_result_t realm_multi_cpu_payload_test(void);
 static test_result_t realm_multi_cpu_payload_del_undel(void);
 
 /* Buffer to delegate and undelegate */
 static char bufferdelegate[NUM_GRANULES * GRANULE_SIZE * PLATFORM_CORE_COUNT] __aligned(GRANULE_SIZE);
 static char bufferstate[NUM_GRANULES * PLATFORM_CORE_COUNT];
-#endif
 
 /*
  * Overall test for realm payload in three sections:
@@ -39,7 +37,6 @@
  * twice and then testing a misaligned address
  */
 
-#ifdef __aarch64__
 test_result_t init_buffer_del(void)
 {
 	u_register_t retrmm;
@@ -58,15 +55,12 @@
 	}
 	return TEST_RESULT_SUCCESS;
 }
-#endif
 
 /*
  * Single CPU version check function
  */
 test_result_t realm_version_single_cpu(void)
 {
-	SKIP_TEST_IF_AARCH32();
-#ifdef __aarch64__
 	u_register_t retrmm;
 
 	if (get_armv9_2_feat_rme_support() == 0U) {
@@ -80,7 +74,6 @@
 			RMI_ABI_VERSION_GET_MINOR(retrmm));
 
 	return TEST_RESULT_SUCCESS;
-#endif
 }
 
 /*
@@ -88,8 +81,6 @@
  */
 test_result_t realm_version_multi_cpu(void)
 {
-	SKIP_TEST_IF_AARCH32();
-#ifdef __aarch64__
 	u_register_t lead_mpid, target_mpid;
 	int cpu_node;
 	long long ret;
@@ -134,7 +125,6 @@
 	}
 
 	return ret;
-#endif
 }
 
 /*
@@ -142,8 +132,6 @@
  */
 test_result_t realm_delegate_undelegate(void)
 {
-	SKIP_TEST_IF_AARCH32();
-#ifdef __aarch64__
 	u_register_t retrmm;
 
 	if (get_armv9_2_feat_rme_support() == 0U) {
@@ -164,21 +152,18 @@
 			(uintptr_t)bufferdelegate);
 
 	return TEST_RESULT_SUCCESS;
-#endif
 }
 
-#ifdef __aarch64__
 static test_result_t realm_multi_cpu_payload_test(void)
 {
 	u_register_t retrmm = realm_version();
 
 	tftf_testcase_printf("Multi CPU RMM version on CPU %llx is: %lu.%lu\n",
-			read_mpidr_el1() & MPID_MASK, RMI_ABI_VERSION_GET_MAJOR(retrmm),
+			(long long)read_mpidr_el1() & MPID_MASK, RMI_ABI_VERSION_GET_MAJOR(retrmm),
 			RMI_ABI_VERSION_GET_MINOR(retrmm));
 
 	return TEST_RESULT_SUCCESS;
 }
-#endif
 
 /*
  * Select all CPU's to randomly delegate/undelegate
@@ -186,11 +171,10 @@
  */
 test_result_t realm_delundel_multi_cpu(void)
 {
-	SKIP_TEST_IF_AARCH32();
-#ifdef __aarch64__
 	u_register_t lead_mpid, target_mpid;
 	int cpu_node;
 	long long ret;
+	u_register_t retrmm;
 
 	if (get_armv9_2_feat_rme_support() == 0U) {
 		return TEST_RESULT_SKIPPED;
@@ -233,9 +217,23 @@
 		}
 	}
 
+	/*
+	 * Cleanup to set all granules back to undelegated
+	 */
+
+	for (int i = 0; i < (NUM_GRANULES * PLATFORM_CORE_COUNT) ; i++) {
+		if (bufferstate[i] == B_DELEGATED) {
+			retrmm = realm_granule_undelegate((u_register_t)&bufferdelegate[i * GRANULE_SIZE]);
+			bufferstate[i] = B_UNDELEGATED;
+			if (retrmm != 0UL) {
+				tftf_testcase_printf("Delegate operation returns fail, %lx\n", retrmm);
+				return TEST_RESULT_FAIL;
+			}
+		}
+	}
+
 	ret = TEST_RESULT_SUCCESS;
 	return ret;
-#endif
 }
 
 /*
@@ -245,7 +243,6 @@
  * assigns NUM_GRANULES to each CPU for delegation or undelgation
  * depending upon the initial state
  */
-#ifdef __aarch64__
 static test_result_t realm_multi_cpu_payload_del_undel(void)
 {
 	u_register_t retrmm;
@@ -270,7 +267,6 @@
 	}
 	return TEST_RESULT_SUCCESS;
 }
-#endif
 
 /*Fail testing of delegation process. The first is an error expected
  * for processing the same granule twice and the second is submission of
@@ -279,11 +275,20 @@
 
 test_result_t realm_fail_del(void)
 {
-	SKIP_TEST_IF_AARCH32();
-#ifdef __aarch64__
+	if (get_armv9_2_feat_rme_support() == 0U) {
+		return TEST_RESULT_SKIPPED;
+	}
+
 	u_register_t retrmm;
 
 	retrmm = realm_granule_delegate((u_register_t)&bufferdelegate[0]);
+
+	if (retrmm != 0UL) {
+		tftf_testcase_printf
+			("Delegate operation does not pass as expected for double delegation, %lx\n", retrmm);
+		return TEST_RESULT_FAIL;
+	}
+
 	retrmm = realm_granule_delegate((u_register_t)&bufferdelegate[0]);
 
 	if (retrmm == 0UL) {
@@ -300,6 +305,13 @@
 		return TEST_RESULT_FAIL;
 	}
 
+	retrmm = realm_granule_undelegate((u_register_t)&bufferdelegate[0]);
+
+	if (retrmm != 0UL) {
+		tftf_testcase_printf
+			("Delegate operation returns fail for cleanup, %lx\n", retrmm);
+		return TEST_RESULT_FAIL;
+	}
+
 	return TEST_RESULT_SUCCESS;
-#endif
 }