feat(memory share): FFA_FEATURES(FFA_MEM_RETRIEVE_REQ)

Updates tests to pass when built against
https://review.trustedfirmware.org/c/hafnium/hafnium/+/18909

Signed-off-by: Karl Meakin <karl.meakin@arm.com>
Change-Id: Ic6c39ca6916b9f9298d7668021963fec287b72c8
diff --git a/include/runtime_services/ffa_helpers.h b/include/runtime_services/ffa_helpers.h
index 3da5c18..8ca51d3 100644
--- a/include/runtime_services/ffa_helpers.h
+++ b/include/runtime_services/ffa_helpers.h
@@ -664,6 +664,8 @@
 struct ffa_value ffa_msg_wait(void);
 struct ffa_value ffa_error(int32_t error_code);
 struct ffa_value ffa_features(uint32_t feature);
+struct ffa_value ffa_features_with_input_property(uint32_t feature,
+                                                  uint32_t param);
 struct ffa_value ffa_partition_info_get(const struct ffa_uuid uuid);
 struct ffa_value ffa_rx_release(void);
 struct ffa_value ffa_rxtx_map(uintptr_t send, uintptr_t recv, uint32_t pages);
diff --git a/include/runtime_services/ffa_svc.h b/include/runtime_services/ffa_svc.h
index 21b0333..6236ae3 100644
--- a/include/runtime_services/ffa_svc.h
+++ b/include/runtime_services/ffa_svc.h
@@ -164,6 +164,8 @@
 #define FFA_NOTIFICATION_INFO_GET_SMC64 \
 	FFA_FID(SMC_64, FFA_FNUM_NOTIFICATION_INFO_GET)
 
+#define FFA_FEATURES_MEM_RETRIEVE_REQ_NS_SUPPORT (UINT32_C(1) << 1)
+
 /* Implementation defined SMC64 FIDs */
 #define FFA_CONSOLE_LOG_SMC64	FFA_FID(SMC_64, FFA_FNUM_CONSOLE_LOG)
 /*
diff --git a/include/runtime_services/spm_common.h b/include/runtime_services/spm_common.h
index 7a81e9c..de5c254 100644
--- a/include/runtime_services/spm_common.h
+++ b/include/runtime_services/spm_common.h
@@ -55,6 +55,7 @@
 	const char *test_name;
 	unsigned int feature;
 	unsigned int expected_ret;
+	unsigned int param;
 	unsigned int version_added;
 };
 
diff --git a/spm/common/sp_tests/sp_test_ffa.c b/spm/common/sp_tests/sp_test_ffa.c
index 80211a8..b130451 100644
--- a/spm/common/sp_tests/sp_test_ffa.c
+++ b/spm/common/sp_tests/sp_test_ffa.c
@@ -88,7 +88,7 @@
 
 		announce_test_start(test_target.test_name);
 
-		ffa_ret = ffa_features(test_target.feature);
+		ffa_ret = ffa_features_with_input_property(test_target.feature, test_target.param);
 		expected_ret = FFA_VERSION_COMPILED
 				>= test_target.version_added ?
 				test_target.expected_ret : FFA_ERROR;
diff --git a/tftf/tests/runtime_services/secure_service/ffa_helpers.c b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
index f737056..1071186 100644
--- a/tftf/tests/runtime_services/secure_service/ffa_helpers.c
+++ b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
@@ -367,6 +367,18 @@
 	return ffa_service_call(&args);
 }
 
+/* Query the higher EL if the requested FF-A feature is implemented. */
+struct ffa_value ffa_features_with_input_property(uint32_t feature, uint32_t param)
+{
+	struct ffa_value args = {
+		.fid = FFA_FEATURES,
+		.arg1 = feature,
+		.arg2 = param,
+	};
+
+	return ffa_service_call(&args);
+}
+
 /* Get information about VMs or SPs based on UUID */
 struct ffa_value ffa_partition_info_get(const struct ffa_uuid uuid)
 {
diff --git a/tftf/tests/runtime_services/secure_service/spm_common.c b/tftf/tests/runtime_services/secure_service/spm_common.c
index 3cd8350..452322a 100644
--- a/tftf/tests/runtime_services/secure_service/spm_common.c
+++ b/tftf/tests/runtime_services/secure_service/spm_common.c
@@ -301,14 +301,15 @@
 	{"FFA_RXTX_UNMAP_32 check", FFA_RXTX_UNMAP, FFA_SUCCESS_SMC32},
 	{"FFA_PARTITION_INFO_GET_32 check", FFA_PARTITION_INFO_GET, FFA_SUCCESS_SMC32},
 	{"FFA_ID_GET_32 check", FFA_ID_GET, FFA_SUCCESS_SMC32},
-	{"FFA_SPM_ID_GET_32 check", FFA_SPM_ID_GET, FFA_SUCCESS_SMC32,
+	{"FFA_SPM_ID_GET_32 check", FFA_SPM_ID_GET, FFA_SUCCESS_SMC32, 0,
 		MAKE_FFA_VERSION(1, 1)},
 	{"FFA_MSG_WAIT_32 check", FFA_MSG_WAIT, FFA_SUCCESS_SMC32},
 	{"FFA_RUN_32 check", FFA_RUN, FFA_SUCCESS_SMC32},
 	{"FFA_MEM_DONATE_32 check", FFA_MEM_DONATE_SMC32, FFA_SUCCESS_SMC32},
 	{"FFA_MEM_LEND_32 check", FFA_MEM_LEND_SMC32, FFA_SUCCESS_SMC32},
 	{"FFA_MEM_SHARE_32 check", FFA_MEM_SHARE_SMC32, FFA_SUCCESS_SMC32},
-	{"FFA_MEM_RETRIEVE_REQ_32 check", FFA_MEM_RETRIEVE_REQ_SMC32, FFA_SUCCESS_SMC32},
+	{"FFA_MEM_RETRIEVE_REQ_32 check", FFA_MEM_RETRIEVE_REQ_SMC32,
+	FFA_SUCCESS_SMC32, FFA_FEATURES_MEM_RETRIEVE_REQ_NS_SUPPORT},
 	{"FFA_MEM_RETRIEVE_RESP_32 check", FFA_MEM_RETRIEVE_RESP, FFA_SUCCESS_SMC32},
 	{"FFA_MEM_RELINQUISH_32 check", FFA_MEM_RELINQUISH, FFA_SUCCESS_SMC32},
 	{"FFA_MEM_RECLAIM_32 check", FFA_MEM_RECLAIM, FFA_SUCCESS_SMC32},
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_setup_and_discovery.c b/tftf/tests/runtime_services/secure_service/test_ffa_setup_and_discovery.c
index e521411..613bdc4 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_setup_and_discovery.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_setup_and_discovery.c
@@ -88,7 +88,7 @@
 
 	for (i = 0U; i < test_target_size; i++) {
 		test_target = ffa_feature_test_target[i];
-		ffa_ret = ffa_features(test_target.feature);
+		ffa_ret = ffa_features_with_input_property(test_target.feature, test_target.param);
 		expected_ret = FFA_VERSION_COMPILED
 			>= test_target.version_added ?
 			test_target.expected_ret : FFA_ERROR;