aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/common/test_helpers.h33
-rw-r--r--include/runtime_services/ffa_helpers.h4
-rw-r--r--tftf/tests/common/test_helpers.c30
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c3
4 files changed, 65 insertions, 5 deletions
diff --git a/include/common/test_helpers.h b/include/common/test_helpers.h
index a6ec0744..4be9aba9 100644
--- a/include/common/test_helpers.h
+++ b/include/common/test_helpers.h
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef __TEST_HELPERS_H__
-#define __TEST_HELPERS_H__
+#ifndef TEST_HELPERS_H__
+#define TEST_HELPERS_H__
#include <uuid.h>
#include <arch_features.h>
@@ -202,9 +202,8 @@ typedef test_result_t (*test_function_arg_t)(void *arg);
} \
} while (0)
-#define SKIP_TEST_IF_FFA_ENDPOINT_NOT_DEPLOYED(mb, uuid) \
+#define SKIP_TEST_IF_FFA_ENDPOINT_NOT_DEPLOYED(mb, ffa_uuid) \
do { \
- const uint32_t ffa_uuid[4] = uuid; \
smc_ret_values smc_ret = ffa_partition_info_get(ffa_uuid); \
ffa_rx_release(); \
if (smc_ret.ret0 == FFA_ERROR && \
@@ -217,6 +216,28 @@ typedef test_result_t (*test_function_arg_t)(void *arg);
} \
} while (0)
+#define GET_TFTF_MAILBOX(mb) \
+ do { \
+ if (!get_tftf_mailbox(&mb)) { \
+ ERROR("Mailbox not configured!\nThis test relies on" \
+ " test suite \"FF-A RXTX Mapping\" to map/configure" \
+ " RXTX buffers\n"); \
+ return TEST_RESULT_FAIL; \
+ } \
+ } while (false);
+
+#define CHECK_HAFNIUM_SPMC_TESTING_SETUP(ffa_major, ffa_minor, expected_uuids) \
+ do { \
+ const size_t expected_uuids_size = \
+ sizeof(expected_uuids) / sizeof(struct ffa_uuid); \
+ test_result_t ret = check_hafnium_spmc_testing_set_up( \
+ ffa_major, ffa_minor, expected_uuids, \
+ expected_uuids_size); \
+ if (ret != TEST_RESULT_SUCCESS) { \
+ return ret; \
+ } \
+ } while (false);
+
/* Helper macro to verify if system suspend API is supported */
#define is_psci_sys_susp_supported() \
(tftf_get_psci_feature_info(SMC_PSCI_SYSTEM_SUSPEND) \
@@ -282,4 +303,8 @@ void set_tftf_mailbox(const struct mailbox_buffers *mb);
*/
bool get_tftf_mailbox(struct mailbox_buffers *mb);
+test_result_t check_hafnium_spmc_testing_set_up(uint32_t ffa_version_major,
+ uint32_t ffa_version_minor, const struct ffa_uuid *ffa_uuids,
+ size_t ffa_uuids_size);
+
#endif /* __TEST_HELPERS_H__ */
diff --git a/include/runtime_services/ffa_helpers.h b/include/runtime_services/ffa_helpers.h
index c91ed5f0..e96787ee 100644
--- a/include/runtime_services/ffa_helpers.h
+++ b/include/runtime_services/ffa_helpers.h
@@ -28,6 +28,10 @@ typedef uint64_t ffa_memory_handle_t;
/** Flags to indicate properties of receivers during memory region retrieval. */
typedef uint8_t ffa_memory_receiver_flags_t;
+struct ffa_uuid {
+ const uint32_t uuid[4];
+};
+
#ifndef __ASSEMBLY__
#include <stdint.h>
diff --git a/tftf/tests/common/test_helpers.c b/tftf/tests/common/test_helpers.c
index b1868cd4..9861070f 100644
--- a/tftf/tests/common/test_helpers.c
+++ b/tftf/tests/common/test_helpers.c
@@ -147,3 +147,33 @@ bool get_tftf_mailbox(struct mailbox_buffers *mb)
}
return false;
}
+
+test_result_t check_hafnium_spmc_testing_set_up(
+ uint32_t ffa_version_major, uint32_t ffa_version_minor,
+ const struct ffa_uuid *ffa_uuids, size_t ffa_uuids_size)
+{
+ struct mailbox_buffers mb;
+
+ if (ffa_uuids == NULL) {
+ ERROR("Invalid parameter ffa_uuids!\n");
+ return TEST_RESULT_FAIL;
+ }
+
+ SKIP_TEST_IF_FFA_VERSION_LESS_THAN(ffa_version_major,
+ ffa_version_minor);
+
+ /**********************************************************************
+ * If OP-TEE is SPMC skip the current test.
+ **********************************************************************/
+ if (check_spmc_execution_level()) {
+ VERBOSE("OPTEE as SPMC at S-EL1. Skipping test!\n");
+ return TEST_RESULT_SKIPPED;
+ }
+
+ GET_TFTF_MAILBOX(mb);
+
+ for (unsigned int i = 0U; i < ffa_uuids_size; i++)
+ SKIP_TEST_IF_FFA_ENDPOINT_NOT_DEPLOYED(*mb, ffa_uuids[i].uuid);
+
+ return TEST_RESULT_SUCCESS;
+}
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c b/tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c
index 6e73161f..fded1998 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c
@@ -30,6 +30,7 @@ static test_result_t test_memory_send_sp(uint32_t mem_func)
ffa_memory_handle_t handle;
uint32_t *ptr;
struct mailbox_buffers mb;
+ const uint32_t primary_uuid[] = PRIMARY_UUID;
/**********************************************************************
* Verify that FFA is there and that it has the correct version.
@@ -55,7 +56,7 @@ static test_result_t test_memory_send_sp(uint32_t mem_func)
/**********************************************************************
* Verify that cactus primary SP is deployed in the system.
**********************************************************************/
- SKIP_TEST_IF_FFA_ENDPOINT_NOT_DEPLOYED(mb, PRIMARY_UUID);
+ SKIP_TEST_IF_FFA_ENDPOINT_NOT_DEPLOYED(mb, primary_uuid);
struct ffa_memory_region_constituent constituents[] = {
{(void *)share_page, 1, 0}