test(ff-a): count flag for ffa_partition_info_get
Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Change-Id: Ib932e70d8f4fef541c67daa3d17666a5a6ebfae0
diff --git a/driver/linux b/driver/linux
index ad9005b..32d7698 160000
--- a/driver/linux
+++ b/driver/linux
@@ -1 +1 @@
-Subproject commit ad9005b23f2821c7843315a367fc9505c639ca29
+Subproject commit 32d76980d9f22536f7604eda5ff386da8a6e24c6
diff --git a/inc/vmapi/hf/call.h b/inc/vmapi/hf/call.h
index 5b6ac0d..84d29a4 100644
--- a/inc/vmapi/hf/call.h
+++ b/inc/vmapi/hf/call.h
@@ -38,13 +38,20 @@
}
/**
- * 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).
+ * Requests information for partitions instantiated in the system. If the
+ * FFA_PARTITION_COUNT_FLAG is not set, 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.
*
+ * Flags may include:
+ * - FFA_PARTITION_COUNT_FLAG, which specifes if the partition info descriptors
+ * are returned in RX buffer or just the count in arg2.
+ * 1 returns just the count.
+ * 0 returns the count with the partition info descriptors.
+ *
* Returns:
* - FFA_SUCCESS on success. The count of partition information descriptors
* populated in the RX buffer is returned in arg2 (register w2).
@@ -53,15 +60,15 @@
* - FFA_INVALID_PARAMETERS for an unrecognized UUID.
*/
static inline struct ffa_value ffa_partition_info_get(
- const struct ffa_uuid *uuid)
+ const struct ffa_uuid *uuid, const uint32_t flags)
{
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]});
+ .arg4 = uuid->uuid[3],
+ .arg5 = flags});
}
-
/**
* DEN0077A FF-A v1.1 Beta0 section 18.3.2.1
* Registers vCPU secondary entry point for the caller VM.
diff --git a/test/vmapi/ffa_secure_partitions/setup_and_discovery.c b/test/vmapi/ffa_secure_partitions/setup_and_discovery.c
index 760d729..a3ddd0e 100644
--- a/test/vmapi/ffa_secure_partitions/setup_and_discovery.c
+++ b/test/vmapi/ffa_secure_partitions/setup_and_discovery.c
@@ -38,7 +38,7 @@
ffa_uuid_init(0, 0, 0, 0, &uuid);
/* Check that expected partition information is returned. */
- ret = ffa_partition_info_get(&uuid);
+ ret = ffa_partition_info_get(&uuid, 0);
EXPECT_EQ(ret.func, FFA_SUCCESS_32);
/* Expect three partitions. */
@@ -59,6 +59,31 @@
EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
}
+TEST(ffa, ffa_partition_info_get_count_flag)
+{
+ struct ffa_value ret;
+ struct ffa_uuid uuid;
+
+ ffa_uuid_init(0, 0, 0, 0, &uuid);
+
+ ret = ffa_partition_info_get(&uuid, FFA_PARTITION_COUNT_FLAG);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
+
+ /* Expect three partitions. */
+ EXPECT_EQ(ret.arg2, 3);
+}
+
+TEST(ffa, ffa_partition_info_get_flags_mbz_fail)
+{
+ struct ffa_value ret;
+ struct ffa_uuid uuid;
+
+ ffa_uuid_init(0, 0, 0, 0, &uuid);
+
+ ret = ffa_partition_info_get(&uuid, 0xffff);
+ EXPECT_FFA_ERROR(ret, FFA_INVALID_PARAMETERS);
+}
+
TEST(ffa, ffa_partition_info_get_uuid_fixed)
{
struct mailbox_buffers mb;
@@ -73,8 +98,19 @@
/* Search for a known secure partition UUID. */
ffa_uuid_init(0xa609f132, 0x6b4f, 0x4c14, 0x9489, &uuid);
+ /* Check that a partition count of 1 is returned. */
+ ret = ffa_partition_info_get(&uuid, FFA_PARTITION_COUNT_FLAG);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
+
+ /* Expect one partition. */
+ EXPECT_EQ(ret.arg2, 1);
+
+ /* And that the buffer is zero */
+ EXPECT_EQ(partitions[0].vm_id, 0);
+ EXPECT_EQ(partitions[0].vcpu_count, 0);
+
/* Check that the expected partition information is returned. */
- ret = ffa_partition_info_get(&uuid);
+ ret = ffa_partition_info_get(&uuid, 0);
EXPECT_EQ(ret.func, FFA_SUCCESS_32);
/* Expect one partition. */
@@ -96,7 +132,7 @@
ffa_uuid_init(1, 1, 1, 1, &uuid);
/* Expect no partition is found with such UUID. */
- ret = ffa_partition_info_get(&uuid);
+ ret = ffa_partition_info_get(&uuid, 0);
EXPECT_EQ(ret.func, FFA_ERROR_32);
}
diff --git a/test/vmapi/primary_only/primary_only.c b/test/vmapi/primary_only/primary_only.c
index cef7478..b1887d1 100644
--- a/test/vmapi/primary_only/primary_only.c
+++ b/test/vmapi/primary_only/primary_only.c
@@ -309,15 +309,20 @@
ffa_uuid_init(0, 0, 0, 0, &uuid);
/* Try to get partition information before the RX buffer is setup. */
- ret = ffa_partition_info_get(&uuid);
+ ret = ffa_partition_info_get(&uuid, 0);
EXPECT_FFA_ERROR(ret, FFA_BUSY);
+ /* Only getting the partition count should succeed however. */
+ ret = ffa_partition_info_get(&uuid, FFA_PARTITION_COUNT_FLAG);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
+ EXPECT_EQ(ret.arg2, 1);
+
/* Setup the mailbox (which holds the RX buffer). */
mb = set_up_mailbox();
partitions = mb.recv;
/* Check that the expected partition information is returned. */
- ret = ffa_partition_info_get(&uuid);
+ ret = ffa_partition_info_get(&uuid, 0);
EXPECT_EQ(ret.func, FFA_SUCCESS_32);
/* There should only be the primary VM in this test. */
EXPECT_EQ(ret.arg2, 1);
@@ -329,14 +334,14 @@
* Check that the partition information cannot be requested if the RX
* buffer is busy.
*/
- ret = ffa_partition_info_get(&uuid);
+ ret = ffa_partition_info_get(&uuid, 0);
EXPECT_FFA_ERROR(ret, FFA_BUSY);
/* Release the buffer and try again. */
ret = ffa_rx_release();
EXPECT_EQ(ret.func, FFA_SUCCESS_32);
- ret = ffa_partition_info_get(&uuid);
+ ret = ffa_partition_info_get(&uuid, 0);
EXPECT_EQ(ret.func, FFA_SUCCESS_32);
ret = ffa_rx_release();
@@ -345,7 +350,7 @@
/* Try to get partition information for an unrecognized UUID. */
ffa_uuid_init(0, 0, 0, 1, &uuid);
- ret = ffa_partition_info_get(&uuid);
+ ret = ffa_partition_info_get(&uuid, 0);
EXPECT_FFA_ERROR(ret, FFA_INVALID_PARAMETERS);
}
diff --git a/test/vmapi/primary_with_secondaries/ffa.c b/test/vmapi/primary_with_secondaries/ffa.c
index f34220d..cfea431 100644
--- a/test/vmapi/primary_with_secondaries/ffa.c
+++ b/test/vmapi/primary_with_secondaries/ffa.c
@@ -163,7 +163,7 @@
/* A Null UUID requests information for all partitions. */
ffa_uuid_init(0, 0, 0, 0, &uuid);
- ret = ffa_partition_info_get(&uuid);
+ ret = ffa_partition_info_get(&uuid, 0);
EXPECT_EQ(ret.func, FFA_SUCCESS_32);
vm_count = ret.arg2;
EXPECT_EQ(vm_count, 4);
diff --git a/test/vmapi/primary_with_secondaries/no_services.c b/test/vmapi/primary_with_secondaries/no_services.c
index 0305973..700bced 100644
--- a/test/vmapi/primary_with_secondaries/no_services.c
+++ b/test/vmapi/primary_with_secondaries/no_services.c
@@ -55,15 +55,20 @@
ffa_uuid_init(0, 0, 0, 0, &uuid);
/* Try to get partition information before the RX buffer is setup. */
- ret = ffa_partition_info_get(&uuid);
+ ret = ffa_partition_info_get(&uuid, 0);
EXPECT_FFA_ERROR(ret, FFA_BUSY);
+ /* Only getting the partition count should succeed however. */
+ ret = ffa_partition_info_get(&uuid, FFA_PARTITION_COUNT_FLAG);
+ EXPECT_EQ(ret.func, FFA_SUCCESS_32);
+ EXPECT_EQ(ret.arg2, 4);
+
/* Setup the mailbox (which holds the RX buffer). */
mb = set_up_mailbox();
partitions = mb.recv;
/* Check that the expected partition information is returned. */
- ret = ffa_partition_info_get(&uuid);
+ ret = ffa_partition_info_get(&uuid, 0);
EXPECT_EQ(ret.func, FFA_SUCCESS_32);
/* Confirm there are 3 secondary VMs as well as this primary VM. */
EXPECT_EQ(ret.arg2, 4);
@@ -88,7 +93,7 @@
/* Try to get partition information for an unrecognized UUID. */
ffa_uuid_init(0, 0, 0, 1, &uuid);
- ret = ffa_partition_info_get(&uuid);
+ ret = ffa_partition_info_get(&uuid, 0);
EXPECT_FFA_ERROR(ret, FFA_INVALID_PARAMETERS);
}