test(ff-a): uuid field for ffa_partition_info_get
The EAC0 v1.1 FF-A spec now requires that the UUID field in the
partition information descriptors is only populated when
FFA_PARTITION_INFO_GET is supplied with a null uuid (Table 13.37).
This patch updates the tests to check for this.
Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Change-Id: I241c6bed4fc5f63ec91a7b86725be5b2ee838601
diff --git a/include/runtime_services/spm_common.h b/include/runtime_services/spm_common.h
index 6dc0e22..cb4fb4d 100644
--- a/include/runtime_services/spm_common.h
+++ b/include/runtime_services/spm_common.h
@@ -47,6 +47,8 @@
#define VM_ID(x) (x & ~SP_ID_MASK)
#define IS_SP_ID(x) ((x & SP_ID_MASK) != 0U)
+#define NULL_UUID (const struct ffa_uuid) { .uuid = {0} }
+
struct ffa_features_test {
const char *test_name;
unsigned int feature;
diff --git a/spm/common/sp_tests/sp_test_ffa.c b/spm/common/sp_tests/sp_test_ffa.c
index f81505a..252eba0 100644
--- a/spm/common/sp_tests/sp_test_ffa.c
+++ b/spm/common/sp_tests/sp_test_ffa.c
@@ -24,7 +24,6 @@
static const struct ffa_uuid sp_uuids[] = {
{PRIMARY_UUID}, {SECONDARY_UUID}, {TERTIARY_UUID}, {IVY_UUID}
};
-static const struct ffa_uuid null_uuid = { .uuid = {0} };
static const struct ffa_partition_info ffa_expected_partition_info[] = {
/* Primary partition info */
@@ -130,7 +129,7 @@
expect(ffa_partition_info_helper(mb, sp_uuids[0],
&ffa_expected_partition_info[0], 1), true);
- expect(ffa_partition_info_helper(mb, null_uuid,
+ expect(ffa_partition_info_helper(mb, NULL_UUID,
ffa_expected_partition_info,
ARRAY_SIZE(ffa_expected_partition_info)), true);
diff --git a/tftf/tests/runtime_services/secure_service/spm_common.c b/tftf/tests/runtime_services/secure_service/spm_common.c
index 571242f..3c4d0dc 100644
--- a/tftf/tests/runtime_services/secure_service/spm_common.c
+++ b/tftf/tests/runtime_services/secure_service/spm_common.c
@@ -516,6 +516,15 @@
total_length, ret);
}
+static 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]) &&
+ (uuid2.uuid[3] == uuid2.uuid[3]);
+}
+
/**
* Sends a ffa_partition_info request and checks the response against the
* target.
@@ -544,6 +553,15 @@
(const struct ffa_partition_info *)(mb->recv);
for (unsigned int i = 0U; i < expected_size; i++) {
+ /*
+ * If a UUID is specified then the UUID returned in the
+ * partition info descriptor MBZ.
+ */
+ struct ffa_uuid expected_uuid =
+ ffa_uuid_equal(uuid, NULL_UUID) ?
+ expected[i].uuid :
+ NULL_UUID;
+
if (info[i].id != expected[i].id) {
ERROR("Wrong ID. Expected %x, got %x\n",
expected[i].id,
@@ -562,16 +580,14 @@
info[i].properties);
result = false;
}
- if (info[i].uuid.uuid[0] != expected[i].uuid.uuid[0] ||
- info[i].uuid.uuid[1] != expected[i].uuid.uuid[1] ||
- info[i].uuid.uuid[2] != expected[i].uuid.uuid[2] ||
- info[i].uuid.uuid[3] != expected[i].uuid.uuid[3]) {
+
+ if (!ffa_uuid_equal(info[i].uuid, expected_uuid)) {
ERROR("Wrong UUID. Expected %x %x %x %x, "
"got %x %x %x %x\n",
- expected[i].uuid.uuid[0],
- expected[i].uuid.uuid[1],
- expected[i].uuid.uuid[2],
- expected[i].uuid.uuid[3],
+ expected_uuid.uuid[0],
+ expected_uuid.uuid[1],
+ expected_uuid.uuid[2],
+ expected_uuid.uuid[3],
info[i].uuid.uuid[0],
info[i].uuid.uuid[1],
info[i].uuid.uuid[2],
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 ae8e7e2..b80f9c4 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
@@ -21,7 +21,6 @@
static const struct ffa_uuid sp_uuids[] = {
{PRIMARY_UUID}, {SECONDARY_UUID}, {TERTIARY_UUID}, {IVY_UUID}
};
-static const struct ffa_uuid null_uuid = { .uuid = {0} };
static const struct ffa_partition_info ffa_expected_partition_info[] = {
/* Primary partition info */
@@ -358,7 +357,7 @@
&ffa_expected_partition_info[2], 1)) {
return TEST_RESULT_FAIL;
}
- if (!ffa_partition_info_helper(&mb, null_uuid,
+ if (!ffa_partition_info_helper(&mb, NULL_UUID,
ffa_expected_partition_info,
ARRAY_SIZE(ffa_expected_partition_info))) {
return TEST_RESULT_FAIL;
@@ -381,7 +380,7 @@
GET_TFTF_MAILBOX(mb);
test_result_t result = TEST_RESULT_SUCCESS;
- struct ffa_value ret = ffa_partition_info_get(null_uuid);
+ struct ffa_value ret = ffa_partition_info_get(NULL_UUID);
uint64_t expected_size = ARRAY_SIZE(ffa_expected_partition_info);
if (ffa_func_id(ret) == FFA_SUCCESS_SMC32) {