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/inc/hf/api.h b/inc/hf/api.h
index 45622fa..974ebdf 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -75,7 +75,8 @@
struct ffa_value api_ffa_id_get(const struct vcpu *current);
struct ffa_value api_ffa_spm_id_get(void);
struct ffa_value api_ffa_feature_success(uint32_t arg2);
-struct ffa_value api_ffa_features(uint32_t function_id);
+struct ffa_value api_ffa_features(uint32_t function_id, uint32_t input_property,
+ uint32_t ffa_version);
struct ffa_value api_ffa_msg_wait(struct vcpu *current, struct vcpu **next,
struct ffa_value *args);
struct ffa_value api_ffa_run(ffa_vm_id_t vm_id, ffa_vcpu_index_t vcpu_idx,
diff --git a/inc/vmapi/hf/call.h b/inc/vmapi/hf/call.h
index 4776421..602b147 100644
--- a/inc/vmapi/hf/call.h
+++ b/inc/vmapi/hf/call.h
@@ -442,10 +442,29 @@
* - FFA_ERROR in .func if the optional interface with function_id is not
* implemented.
*/
-static inline struct ffa_value ffa_features(uint32_t function_id)
+static inline struct ffa_value ffa_features(uint64_t function_id)
{
- return ffa_call((struct ffa_value){.func = FFA_FEATURES_32,
- .arg1 = function_id});
+ return ffa_call((struct ffa_value){
+ .func = FFA_FEATURES_32,
+ .arg1 = function_id,
+ });
+}
+
+/**
+ * Discovery function returning information about the implementation of optional
+ * FF-A interfaces which require an extra input property
+ *
+ * Returns:
+ * - FFA_SUCCESS in .func if the optional interface with function_id is
+ * implemented.
+ * - FFA_ERROR in .func if the optional interface with function_id is not
+ * implemented.
+ */
+static inline struct ffa_value ffa_features_with_input_property(
+ uint64_t function_id, uint64_t param)
+{
+ return ffa_call((struct ffa_value){
+ .func = FFA_FEATURES_32, .arg1 = function_id, .arg2 = param});
}
static inline struct ffa_value ffa_msg_send_direct_req(
diff --git a/inc/vmapi/hf/ffa.h b/inc/vmapi/hf/ffa.h
index 4db2c14..5717aa6 100644
--- a/inc/vmapi/hf/ffa.h
+++ b/inc/vmapi/hf/ffa.h
@@ -107,6 +107,21 @@
#define FFA_FEATURES_FUNC_ID_MASK (UINT32_C(1) << 31)
#define FFA_FEATURES_FEATURE_ID_MASK UINT32_C(0x7F)
+/**
+ * Defined in Table 13.14 in the FF-A v.1.1 REL0 specification.
+ * Bits[31:2] and Bit[0] of input are reserved (must be zero).
+ * Bit[0]: dynamically allocated buffer support.
+ * Bit[1]: NS bit handling.
+ * Bit[2]: support for retrieval by hypervisor.
+ */
+#define FFA_FEATURES_MEM_RETRIEVE_REQ_BUFFER_SUPPORT 0
+#define FFA_FEATURES_MEM_RETRIEVE_REQ_NS_SUPPORT (UINT32_C(1) << 1)
+#define FFA_FEATURES_MEM_RETRIEVE_REQ_HYPERVISOR_SUPPORT (UINT32_C(1) << 2)
+#define FFA_FEATURES_MEM_RETRIEVE_REQ_MBZ_MASK \
+ (~(FFA_FEATURES_MEM_RETRIEVE_REQ_BUFFER_SUPPORT | \
+ FFA_FEATURES_MEM_RETRIEVE_REQ_NS_SUPPORT | \
+ FFA_FEATURES_MEM_RETRIEVE_REQ_HYPERVISOR_SUPPORT))
+
/* Query interrupt ID of Notification Pending Interrupt. */
#define FFA_FEATURE_NPI 0x1U