feat(memory share): FFA_FEATURES(FFA_MEM_RETRIEVE_REQ)
Table 13.14 in the FF-A v.1.1 REL0 specification requires bits 31:2
and bit 0 of the input parameter to be 0 (MBZ) when querying
`FFA_FEATURES` for `FFA_MEM_RETRIEVE_REQ`.
It also requires that the return parameter must report support for
dynamically allocated buffers (bit 0), support for the NS bit (bit 1),
and support for retrieval by the hypervisor (bit 2).
This patch modifies `api_ffa_features` to validate the input parameters
and report feature support when the function id is
`FFA_MEM_RETRIEVE_REQ`
Signed-off-by: Karl Meakin <karl.meakin@arm.com>
Change-Id: Ie415083ba0e5cd506a1162ff9649e3e188e83737
diff --git a/src/api.c b/src/api.c
index 18e2f97..9ceb743 100644
--- a/src/api.c
+++ b/src/api.c
@@ -2385,7 +2385,8 @@
* Discovery function returning information about the implementation of optional
* FF-A interfaces.
*/
-struct ffa_value api_ffa_features(uint32_t feature_function_id)
+struct ffa_value api_ffa_features(uint32_t feature_function_id,
+ uint32_t input_property, uint32_t ffa_version)
{
/*
* According to table 13.8 of FF-A v1.1 Beta 0 spec, bits [30:8] MBZ
@@ -2396,6 +2397,14 @@
return ffa_error(FFA_NOT_SUPPORTED);
}
+ if (feature_function_id != FFA_MEM_RETRIEVE_REQ_32 &&
+ input_property != 0U) {
+ dlog_verbose(
+ "input_property must be zero.\ninput_property = %u.\n",
+ input_property);
+ return ffa_error(FFA_INVALID_PARAMETERS);
+ }
+
switch (feature_function_id) {
/* Check support of the given Function ID. */
case FFA_ERROR_32:
@@ -2413,7 +2422,6 @@
case FFA_MEM_DONATE_32:
case FFA_MEM_LEND_32:
case FFA_MEM_SHARE_32:
- case FFA_MEM_RETRIEVE_REQ_32:
case FFA_MEM_RETRIEVE_RESP_32:
case FFA_MEM_RELINQUISH_32:
case FFA_MEM_RECLAIM_32:
@@ -2441,6 +2449,29 @@
case FFA_PARTITION_INFO_GET_REGS_64:
#endif
return (struct ffa_value){.func = FFA_SUCCESS_32};
+ case FFA_MEM_RETRIEVE_REQ_32:
+ if ((input_property & FFA_FEATURES_MEM_RETRIEVE_REQ_MBZ_MASK) !=
+ 0U) {
+ dlog_verbose(
+ "Bits[31:2] and Bit[0] of input_property must "
+ "be zero.\ninput_property = %u.\n",
+ input_property);
+ return ffa_error(FFA_INVALID_PARAMETERS);
+ }
+
+ if (ffa_version >= MAKE_FFA_VERSION(1, 1)) {
+ if ((input_property &
+ FFA_FEATURES_MEM_RETRIEVE_REQ_NS_SUPPORT) == 0U) {
+ dlog_verbose("NS bit support must be 1.\n");
+ return ffa_error(FFA_INVALID_PARAMETERS);
+ }
+ }
+
+ return api_ffa_feature_success(
+ FFA_FEATURES_MEM_RETRIEVE_REQ_BUFFER_SUPPORT |
+ (input_property &
+ FFA_FEATURES_MEM_RETRIEVE_REQ_NS_SUPPORT) |
+ FFA_FEATURES_MEM_RETRIEVE_REQ_HYPERVISOR_SUPPORT);
#if (MAKE_FFA_VERSION(1, 1) <= FFA_VERSION_COMPILED)
/* Check support of a feature provided respective feature ID. */