Add support for FFA_PARTITION_INFO_GET
Add support for FFA_PARTITION_INFO_GET, which returns
information on the partitions instantiated in the system.
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: I93070fe841b4b19c596645246203dbba14eddb12
diff --git a/inc/hf/api.h b/inc/hf/api.h
index 2c092ec..f9f8cca 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -48,6 +48,8 @@
struct vcpu **next);
void api_yield(struct vcpu *current, struct vcpu **next);
struct ffa_value api_ffa_version(uint32_t requested_version);
+struct ffa_value api_ffa_partition_info_get(struct vcpu *current,
+ const struct ffa_uuid *uuid);
struct ffa_value api_ffa_id_get(const struct vcpu *current);
struct ffa_value api_ffa_features(uint32_t function_id);
struct ffa_value api_ffa_run(ffa_vm_id_t vm_id, ffa_vcpu_index_t vcpu_idx,
diff --git a/inc/hf/manifest.h b/inc/hf/manifest.h
index 9e571b1..88f3b6e 100644
--- a/inc/hf/manifest.h
+++ b/inc/hf/manifest.h
@@ -47,7 +47,7 @@
/** PSA-FF-A expected version - mandatory */
uint32_t ffa_version;
/** UUID - mandatory */
- uint32_t uuid[4];
+ struct ffa_uuid uuid;
/** Partition id - optional */
ffa_vm_id_t id;
/** Aux ids for mem transactions - optional */
diff --git a/inc/hf/vm.h b/inc/hf/vm.h
index d45b476..cf03b0c 100644
--- a/inc/hf/vm.h
+++ b/inc/hf/vm.h
@@ -100,6 +100,7 @@
struct vm {
ffa_vm_id_t id;
+ struct ffa_uuid uuid;
struct smc_whitelist smc_whitelist;
/** See api.c for the partial ordering on locks. */
@@ -140,6 +141,7 @@
struct vm **new_vm);
ffa_vm_count_t vm_get_count(void);
struct vm *vm_find(ffa_vm_id_t id);
+struct vm *vm_find_index(uint16_t index);
struct vm_locked vm_lock(struct vm *vm);
struct two_vm_locked vm_lock_both(struct vm *vm1, struct vm *vm2);
void vm_unlock(struct vm_locked *locked);
diff --git a/inc/vmapi/hf/call.h b/inc/vmapi/hf/call.h
index 719da62..8a29933 100644
--- a/inc/vmapi/hf/call.h
+++ b/inc/vmapi/hf/call.h
@@ -28,6 +28,31 @@
}
/**
+ * Requests information for partitions instantiated in the system. The
+ * information is returned in the RX buffer of the caller as an array of
+ * partition information descriptors (struct ffa_partition_info).
+ *
+ * A Null UUID (UUID that is all zeros) returns information for all partitions,
+ * whereas a non-Null UUID returns information only for partitions that match.
+ *
+ * Returns:
+ * - FFA_SUCCESS on success. The count of partition information descriptors
+ * populated in the RX buffer is returned in arg2 (register w2).
+ * - FFA_BUSY if the caller's RX buffer is not free.
+ * - FFA_NO_MEMORY if the results do not fit in the callers RX buffer.
+ * - FFA_INVALID_PARAMETERS for an unrecognized UUID.
+ */
+static inline struct ffa_value ffa_partition_info_get(
+ const struct ffa_uuid *uuid)
+{
+ return ffa_call((struct ffa_value){.func = FFA_PARTITION_INFO_GET_32,
+ .arg1 = uuid->uuid[0],
+ .arg2 = uuid->uuid[1],
+ .arg3 = uuid->uuid[2],
+ .arg4 = uuid->uuid[3]});
+}
+
+/**
* Returns the VM's own ID.
*/
static inline ffa_vm_id_t hf_vm_get_id(void)
diff --git a/inc/vmapi/hf/ffa.h b/inc/vmapi/hf/ffa.h
index 02c0777..bc85337 100644
--- a/inc/vmapi/hf/ffa.h
+++ b/inc/vmapi/hf/ffa.h
@@ -290,6 +290,71 @@
}
/**
+ * Holds the UUID in a struct that is mappable directly to the SMCC calling
+ * convention, which is used for FF-A calls.
+ *
+ * Refer to table 84 of the FF-A 1.0 EAC specification as well as section 5.3
+ * of the SMCC Spec 1.2.
+ */
+struct ffa_uuid {
+ uint32_t uuid[4];
+};
+
+static inline void ffa_uuid_init(uint32_t w0, uint32_t w1, uint32_t w2,
+ uint32_t w3, struct ffa_uuid *uuid)
+{
+ uuid->uuid[0] = w0;
+ uuid->uuid[1] = w1;
+ uuid->uuid[2] = w2;
+ uuid->uuid[3] = w3;
+}
+
+static inline bool ffa_uuid_equal(const struct ffa_uuid *uuid1,
+ const struct ffa_uuid *uuid2)
+{
+ return (uuid1->uuid[0] == uuid2->uuid[0]) &&
+ (uuid1->uuid[1] == uuid2->uuid[1]) &&
+ (uuid1->uuid[2] == uuid2->uuid[2]) &&
+ (uuid1->uuid[3] == uuid2->uuid[3]);
+}
+
+static inline bool ffa_uuid_is_null(const struct ffa_uuid *uuid)
+{
+ return (uuid->uuid[0] == 0) && (uuid->uuid[1] == 0) &&
+ (uuid->uuid[2] == 0) && (uuid->uuid[3] == 0);
+}
+
+/**
+ * Flags to determine the partition properties, as required by
+ * FFA_PARTITION_INFO_GET.
+ *
+ * The values of the flags are specified in table 82 of the FF-A 1.0 EAC
+ * specification, "Partition information descriptor, partition properties".
+ */
+typedef uint32_t ffa_partition_properties_t;
+
+/** Partition property: partition supports receipt of direct requests. */
+#define FFA_PARTITION_DIRECT_RECV 0x1
+
+/** Partition property: partition can send direct requests. */
+#define FFA_PARTITION_DIRECT_SEND 0x2
+
+/** Partition property: partition can send and receive indirect messages. */
+#define FFA_PARTITION_INDIRECT_MSG 0x4
+
+/**
+ * Holds information returned for each partition by the FFA_PARTITION_INFO_GET
+ * interface.
+ * This corresponds to table 82 of the FF-A 1.0 EAC specification, "Partition
+ * information descriptor".
+ */
+struct ffa_partition_info {
+ ffa_vm_id_t vm_id;
+ ffa_vcpu_count_t vcpu_count;
+ ffa_partition_properties_t properties;
+};
+
+/**
* A set of contiguous pages which is part of a memory region. This corresponds
* to table 40 of the FF-A 1.0 EAC specification, "Constituent memory region
* descriptor".