aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Shvetsov <maksims.svecovs@arm.com>2021-02-04 16:58:31 +0000
committerMax Shvetsov <maksims.svecovs@arm.com>2021-02-10 11:56:46 +0000
commit103e056ba016d10809948657f6b4f0de93779bc4 (patch)
treed527dceccfce849895db594fa9bac144d63ee59b
parentdb4a2a7453741f86e350a6e296879970da0ec9bf (diff)
downloadtf-a-tests-103e056ba016d10809948657f6b4f0de93779bc4.tar.gz
[SPM] tidying common code to tftf and cactus
This patch moves the code used to test SPM functionality, not explicitly described in FF-A specification, from ffa_helpers to spm_common which is built for both tftf and cactus. Signed-off-by: Max Shvetsov <maksims.svecovs@arm.com> Change-Id: I461efad977cc4d02701feea7b2215a61453716ef
-rw-r--r--include/common/test_helpers.h8
-rw-r--r--include/runtime_services/ffa_helpers.h44
-rw-r--r--include/runtime_services/spm_common.h64
-rw-r--r--spm/cactus/cactus.mk3
-rw-r--r--spm/cactus/cactus_ffa_tests.c54
-rw-r--r--spm/cactus/cactus_main.c19
-rw-r--r--spm/cactus/cactus_tests.h4
-rw-r--r--tftf/tests/common/test_helpers.c3
-rw-r--r--tftf/tests/runtime_services/secure_service/ffa_helpers.c46
-rw-r--r--tftf/tests/runtime_services/secure_service/spm_common.c92
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c10
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_features.c54
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c6
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c4
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_version.c3
-rw-r--r--tftf/tests/tests-spm.mk5
16 files changed, 214 insertions, 205 deletions
diff --git a/include/common/test_helpers.h b/include/common/test_helpers.h
index 3f69df9e..3ee2b531 100644
--- a/include/common/test_helpers.h
+++ b/include/common/test_helpers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -7,16 +7,16 @@
#ifndef TEST_HELPERS_H__
#define TEST_HELPERS_H__
-#include <uuid.h>
#include <arch_features.h>
-#include <ffa_helpers.h>
#include <ffa_svc.h>
+#include <plat_topology.h>
#include <psci.h>
+#include <spm_common.h>
#include <tftf_lib.h>
#include <trusted_os.h>
#include <tsp.h>
#include <uuid_utils.h>
-#include <plat_topology.h>
+#include <uuid.h>
typedef struct {
uintptr_t addr;
diff --git a/include/runtime_services/ffa_helpers.h b/include/runtime_services/ffa_helpers.h
index b8928d43..caeaa9e0 100644
--- a/include/runtime_services/ffa_helpers.h
+++ b/include/runtime_services/ffa_helpers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -14,21 +14,6 @@
/* This error code must be different to the ones used by FFA */
#define FFA_TFTF_ERROR -42
-/* Hypervisor ID at physical FFA instance */
-#define HYP_ID (0)
-
-/*
- * The bit 15 of the FF-A ID indicates whether the partition is executing
- * in the normal world, in case it is a Virtual Machine (VM); or in the
- * secure world, in case it is a Secure Partition (SP).
- *
- * If bit 15 is set partition is an SP; if bit 15 is clear partition is
- * a VM.
- */
-#define SP_ID_MASK U(1 << 15)
-#define SP_ID(x) ((x) | SP_ID_MASK)
-#define IS_SP_ID(x) ((x & SP_ID_MASK) != 0U)
-
typedef unsigned short ffa_vm_id_t;
typedef unsigned short ffa_vm_count_t;
typedef unsigned short ffa_vcpu_count_t;
@@ -45,32 +30,6 @@ struct ffa_uuid {
#include <stdint.h>
-struct mailbox_buffers {
- void *recv;
- void *send;
-};
-
-#define CONFIGURE_MAILBOX(mb_name, buffers_size) \
- do { \
- /* Declare RX/TX buffers at virtual FF-A instance */ \
- static struct { \
- uint8_t rx[buffers_size]; \
- uint8_t tx[buffers_size]; \
- } __aligned(PAGE_SIZE) mb_buffers; \
- mb_name.recv = (void *)mb_buffers.rx; \
- mb_name.send = (void *)mb_buffers.tx; \
- } while (false)
-
-#define CONFIGURE_AND_MAP_MAILBOX(mb_name, buffers_size, smc_ret) \
- do { \
- CONFIGURE_MAILBOX(mb_name, buffers_size); \
- smc_ret = ffa_rxtx_map( \
- (uintptr_t)mb_name.send, \
- (uintptr_t)mb_name.recv, \
- buffers_size / PAGE_SIZE \
- ); \
- } while (false)
-
struct ffa_partition_info {
/** The ID of the VM the information is about */
ffa_vm_id_t id;
@@ -407,7 +366,6 @@ ffa_memory_handle_t ffa_memory_init_and_send(
const struct ffa_memory_region_constituent* constituents,
uint32_t constituents_count, uint32_t mem_func);
-bool check_spmc_execution_level(void);
smc_ret_values ffa_msg_send_direct_req(uint32_t source_id, uint32_t dest_id, uint32_t message);
smc_ret_values ffa_msg_send_direct_req64(uint32_t source_id, uint32_t dest_id, uint64_t message);
smc_ret_values ffa_msg_send_direct_req64_5args(uint32_t source_id, uint32_t dest_id,
diff --git a/include/runtime_services/spm_common.h b/include/runtime_services/spm_common.h
new file mode 100644
index 00000000..f264af9a
--- /dev/null
+++ b/include/runtime_services/spm_common.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef SPM_COMMON_H
+#define SPM_COMMON_H
+
+#include <ffa_helpers.h>
+#include <stdint.h>
+#include <string.h>
+
+/* Hypervisor ID at physical FFA instance */
+#define HYP_ID (0)
+
+/*
+ * The bit 15 of the FF-A ID indicates whether the partition is executing
+ * in the normal world, in case it is a Virtual Machine (VM); or in the
+ * secure world, in case it is a Secure Partition (SP).
+ *
+ * If bit 15 is set partition is an SP; if bit 15 is clear partition is
+ * a VM.
+ */
+#define SP_ID_MASK U(1 << 15)
+#define SP_ID(x) ((x) | SP_ID_MASK)
+#define IS_SP_ID(x) ((x & SP_ID_MASK) != 0U)
+
+struct ffa_features_test {
+ const char *test_name;
+ unsigned int feature;
+ unsigned int expected_ret;
+};
+unsigned int get_ffa_feature_test_target(const struct ffa_features_test **test_target);
+
+struct mailbox_buffers {
+ void *recv;
+ void *send;
+};
+
+#define CONFIGURE_MAILBOX(mb_name, buffers_size) \
+ do { \
+ /* Declare RX/TX buffers at virtual FF-A instance */ \
+ static struct { \
+ uint8_t rx[buffers_size]; \
+ uint8_t tx[buffers_size]; \
+ } __aligned(PAGE_SIZE) mb_buffers; \
+ mb_name.recv = (void *)mb_buffers.rx; \
+ mb_name.send = (void *)mb_buffers.tx; \
+ } while (false)
+
+#define CONFIGURE_AND_MAP_MAILBOX(mb_name, buffers_size, smc_ret) \
+ do { \
+ CONFIGURE_MAILBOX(mb_name, buffers_size); \
+ smc_ret = ffa_rxtx_map( \
+ (uintptr_t)mb_name.send, \
+ (uintptr_t)mb_name.recv, \
+ buffers_size / PAGE_SIZE \
+ ); \
+ } while (false)
+
+bool check_spmc_execution_level(void);
+
+#endif /* SPM_COMMON_H */
diff --git a/spm/cactus/cactus.mk b/spm/cactus/cactus.mk
index 4b3f0bd3..4a9cfcc2 100644
--- a/spm/cactus/cactus.mk
+++ b/spm/cactus/cactus.mk
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2018-2021, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -46,6 +46,7 @@ CACTUS_SOURCES += \
tftf/framework/debug.c \
tftf/framework/${ARCH}/asm_debug.S \
tftf/tests/runtime_services/secure_service/ffa_helpers.c \
+ tftf/tests/runtime_services/secure_service/spm_common.c \
tftf/framework/${ARCH}/exceptions.S \
tftf/framework/${ARCH}/exception_report.c
diff --git a/spm/cactus/cactus_ffa_tests.c b/spm/cactus/cactus_ffa_tests.c
index 5863456a..a5acc567 100644
--- a/spm/cactus/cactus_ffa_tests.c
+++ b/spm/cactus/cactus_ffa_tests.c
@@ -1,16 +1,17 @@
/*
- * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <assert.h>
#include <debug.h>
#include <errno.h>
-#include <cactus_platform_def.h>
+
#include <cactus_def.h>
+#include <cactus_platform_def.h>
#include <ffa_endpoints.h>
-#include <ffa_helpers.h>
#include <sp_helpers.h>
+#include <spm_common.h>
#include <lib/libc/string.h>
#include <lib/xlat_tables/xlat_tables_v2.h>
@@ -24,39 +25,6 @@ static const uint32_t secondary_uuid[4] = SECONDARY_UUID;
static const uint32_t tertiary_uuid[4] = TERTIARY_UUID;
static const uint32_t null_uuid[4] = {0};
-struct feature_test {
- const char *test_name;
- unsigned int feature;
- unsigned int expected_ret;
-};
-
-static const struct feature_test test_target[] = {
- {"FFA_ERROR_32 check", FFA_ERROR, FFA_SUCCESS_SMC32},
- {"FFA_SUCCESS_32 check", FFA_SUCCESS_SMC32, FFA_SUCCESS_SMC32},
- {"FFA_INTERRUPT_32 check", FFA_INTERRUPT, FFA_SUCCESS_SMC32},
- {"FFA_VERSION_32 check", FFA_VERSION, FFA_SUCCESS_SMC32},
- {"FFA_FEATURES_32 check", FFA_FEATURES, FFA_SUCCESS_SMC32},
- {"FFA_RX_RELEASE_32 check", FFA_RX_RELEASE, FFA_SUCCESS_SMC32},
- {"FFA_RXTX_MAP_32 check", FFA_RXTX_MAP_SMC32, FFA_ERROR},
- {"FFA_RXTX_MAP_64 check", FFA_RXTX_MAP_SMC64, FFA_SUCCESS_SMC32},
- {"FFA_RXTX_UNMAP_32 check", FFA_RXTX_UNMAP, FFA_ERROR},
- {"FFA_PARTITION_INFO_GET_32 check", FFA_PARTITION_INFO_GET, FFA_SUCCESS_SMC32},
- {"FFA_ID_GET_32 check", FFA_ID_GET, FFA_SUCCESS_SMC32},
- {"FFA_MSG_POLL_32 check", FFA_MSG_POLL, FFA_SUCCESS_SMC32},
- {"FFA_MSG_WAIT_32 check", FFA_MSG_WAIT, FFA_SUCCESS_SMC32},
- {"FFA_YIELD_32 check", FFA_MSG_YIELD, FFA_SUCCESS_SMC32},
- {"FFA_RUN_32 check", FFA_MSG_RUN, FFA_SUCCESS_SMC32},
- {"FFA_MSG_SEND_32 check", FFA_MSG_SEND, FFA_SUCCESS_SMC32},
- {"FFA_MEM_DONATE_32 check", FFA_MEM_DONATE_SMC32, FFA_SUCCESS_SMC32},
- {"FFA_MEM_LEND_32 check", FFA_MEM_LEND_SMC32, FFA_SUCCESS_SMC32},
- {"FFA_MEM_SHARE_32 check", FFA_MEM_SHARE_SMC32, FFA_SUCCESS_SMC32},
- {"FFA_MEM_RETRIEVE_REQ_32 check", FFA_MEM_RETRIEVE_REQ_SMC32, FFA_SUCCESS_SMC32},
- {"FFA_MEM_RETRIEVE_RESP_32 check", FFA_MEM_RETRIEVE_RESP, FFA_SUCCESS_SMC32},
- {"FFA_MEM_RELINQUISH_32 check", FFA_MEM_RELINQUISH, FFA_SUCCESS_SMC32},
- {"FFA_MEM_RECLAIM_32 check", FFA_MEM_RECLAIM, FFA_SUCCESS_SMC32},
- {"Check non-existent command", 0xFFFF, FFA_ERROR}
-};
-
/*
* Test FFA_FEATURES interface.
*/
@@ -64,21 +32,23 @@ static void ffa_features_test(void)
{
const char *test_features = "FFA Features interface";
smc_ret_values ffa_ret;
+ const struct ffa_features_test *ffa_feature_test_target;
unsigned int i, test_target_size =
- sizeof(test_target) / sizeof(struct feature_test);
+ get_ffa_feature_test_target(&ffa_feature_test_target);
+
announce_test_section_start(test_features);
for (i = 0U; i < test_target_size; i++) {
- announce_test_start(test_target[i].test_name);
+ announce_test_start(ffa_feature_test_target[i].test_name);
- ffa_ret = ffa_features(test_target[i].feature);
- expect(ffa_ret.ret0, test_target[i].expected_ret);
- if (test_target[i].expected_ret == FFA_ERROR) {
+ ffa_ret = ffa_features(ffa_feature_test_target[i].feature);
+ expect(ffa_ret.ret0, ffa_feature_test_target[i].expected_ret);
+ if (ffa_feature_test_target[i].expected_ret == FFA_ERROR) {
expect(ffa_ret.ret2, FFA_ERROR_NOT_SUPPORTED);
}
- announce_test_end(test_target[i].test_name);
+ announce_test_end(ffa_feature_test_target[i].test_name);
}
announce_test_section_end(test_features);
diff --git a/spm/cactus/cactus_main.c b/spm/cactus/cactus_main.c
index e1bfd1fd..1d81988f 100644
--- a/spm/cactus/cactus_main.c
+++ b/spm/cactus/cactus_main.c
@@ -1,30 +1,29 @@
/*
- * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <assert.h>
#include <errno.h>
+#include <debug.h>
-#include "cactus.h"
-#include "cactus_def.h"
#include <cactus_platform_def.h>
-#include "cactus_tests.h"
-#include <debug.h>
+#include <cactus_test_cmds.h>
#include <drivers/arm/pl011.h>
#include <drivers/console.h>
-#include <ffa_helpers.h>
#include <lib/aarch64/arch_helpers.h>
#include <lib/xlat_tables/xlat_mmu_helpers.h>
#include <lib/xlat_tables/xlat_tables_v2.h>
-#include <sp_helpers.h>
-#include <std_svc.h>
-#include <plat/common/platform.h>
#include <plat_arm.h>
+#include <plat/common/platform.h>
#include <platform_def.h>
+#include <sp_helpers.h>
+#include <std_svc.h>
-#include <cactus_test_cmds.h>
+#include "cactus_def.h"
+#include "cactus_tests.h"
+#include "cactus.h"
/* Host machine information injected by the build system in the ELF file. */
extern const char build_message[];
diff --git a/spm/cactus/cactus_tests.h b/spm/cactus/cactus_tests.h
index fd229bf5..8e838cc7 100644
--- a/spm/cactus/cactus_tests.h
+++ b/spm/cactus/cactus_tests.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -7,7 +7,7 @@
#ifndef CACTUS_TESTS_H
#define CACTUS_TESTS_H
-#include <ffa_helpers.h>
+#include <spm_common.h>
/*
* Test functions
diff --git a/tftf/tests/common/test_helpers.c b/tftf/tests/common/test_helpers.c
index 05b09d7c..d794bebc 100644
--- a/tftf/tests/common/test_helpers.c
+++ b/tftf/tests/common/test_helpers.c
@@ -1,11 +1,10 @@
/*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <arch_helpers.h>
-#include <ffa_helpers.h>
#include <plat_topology.h>
#include <platform.h>
#include <power_management.h>
diff --git a/tftf/tests/runtime_services/secure_service/ffa_helpers.c b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
index 1b790188..7d94d278 100644
--- a/tftf/tests/runtime_services/secure_service/ffa_helpers.c
+++ b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
@@ -1,11 +1,12 @@
/*
- * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <debug.h>
#include <smccc.h>
+
#include <ffa_endpoints.h>
#include <ffa_helpers.h>
#include <ffa_svc.h>
@@ -108,49 +109,6 @@ smc_ret_values ffa_msg_send_direct_req64(uint32_t source_id, uint32_t dest_id,
message, 0, 0, 0, 0);
}
-/*
- * check_spmc_execution_level
- *
- * Attempt sending impdef protocol messages to OP-TEE through direct messaging.
- * Criteria for detecting OP-TEE presence is that responses match defined
- * version values. In the case of SPMC running at S-EL2 (and Cactus instances
- * running at S-EL1) the response will not match the pre-defined version IDs.
- *
- * Returns true if SPMC is probed as being OP-TEE at S-EL1.
- *
- */
-bool check_spmc_execution_level(void)
-{
- unsigned int is_optee_spmc_criteria = 0U;
- smc_ret_values ret_values;
-
- /*
- * Send a first OP-TEE-defined protocol message through
- * FFA direct message.
- *
- */
- ret_values = ffa_msg_send_direct_req(HYP_ID, SP_ID(1),
- OPTEE_FFA_GET_API_VERSION);
- if ((ret_values.ret3 == FFA_VERSION_MAJOR) &&
- (ret_values.ret4 == FFA_VERSION_MINOR)) {
- is_optee_spmc_criteria++;
- }
-
- /*
- * Send a second OP-TEE-defined protocol message through
- * FFA direct message.
- *
- */
- ret_values = ffa_msg_send_direct_req(HYP_ID, SP_ID(1),
- OPTEE_FFA_GET_OS_VERSION);
- if ((ret_values.ret3 == OPTEE_FFA_GET_OS_VERSION_MAJOR) &&
- (ret_values.ret4 == OPTEE_FFA_GET_OS_VERSION_MINOR)) {
- is_optee_spmc_criteria++;
- }
-
- return (is_optee_spmc_criteria == 2U);
-}
-
/**
* Initialises the header of the given `ffa_memory_region`, not including the
* composite memory region offset.
diff --git a/tftf/tests/runtime_services/secure_service/spm_common.c b/tftf/tests/runtime_services/secure_service/spm_common.c
new file mode 100644
index 00000000..74a19a6a
--- /dev/null
+++ b/tftf/tests/runtime_services/secure_service/spm_common.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <ffa_endpoints.h>
+#include <spm_common.h>
+
+/*
+ * check_spmc_execution_level
+ *
+ * Attempt sending impdef protocol messages to OP-TEE through direct messaging.
+ * Criteria for detecting OP-TEE presence is that responses match defined
+ * version values. In the case of SPMC running at S-EL2 (and Cactus instances
+ * running at S-EL1) the response will not match the pre-defined version IDs.
+ *
+ * Returns true if SPMC is probed as being OP-TEE at S-EL1.
+ *
+ */
+bool check_spmc_execution_level(void)
+{
+ unsigned int is_optee_spmc_criteria = 0U;
+ smc_ret_values ret_values;
+
+ /*
+ * Send a first OP-TEE-defined protocol message through
+ * FFA direct message.
+ */
+ ret_values = ffa_msg_send_direct_req(HYP_ID, SP_ID(1),
+ OPTEE_FFA_GET_API_VERSION);
+ if ((ret_values.ret3 == FFA_VERSION_MAJOR) &&
+ (ret_values.ret4 == FFA_VERSION_MINOR)) {
+ is_optee_spmc_criteria++;
+ }
+
+ /*
+ * Send a second OP-TEE-defined protocol message through
+ * FFA direct message.
+ */
+ ret_values = ffa_msg_send_direct_req(HYP_ID, SP_ID(1),
+ OPTEE_FFA_GET_OS_VERSION);
+ if ((ret_values.ret3 == OPTEE_FFA_GET_OS_VERSION_MAJOR) &&
+ (ret_values.ret4 == OPTEE_FFA_GET_OS_VERSION_MINOR)) {
+ is_optee_spmc_criteria++;
+ }
+
+ return (is_optee_spmc_criteria == 2U);
+}
+
+static const struct ffa_features_test ffa_feature_test_target[] = {
+ {"FFA_ERROR_32 check", FFA_ERROR, FFA_SUCCESS_SMC32},
+ {"FFA_SUCCESS_32 check", FFA_SUCCESS_SMC32, FFA_SUCCESS_SMC32},
+ {"FFA_INTERRUPT_32 check", FFA_INTERRUPT, FFA_SUCCESS_SMC32},
+ {"FFA_VERSION_32 check", FFA_VERSION, FFA_SUCCESS_SMC32},
+ {"FFA_FEATURES_32 check", FFA_FEATURES, FFA_SUCCESS_SMC32},
+ {"FFA_RX_RELEASE_32 check", FFA_RX_RELEASE, FFA_SUCCESS_SMC32},
+ {"FFA_RXTX_MAP_32 check", FFA_RXTX_MAP_SMC32, FFA_ERROR},
+ {"FFA_RXTX_MAP_64 check", FFA_RXTX_MAP_SMC64, FFA_SUCCESS_SMC32},
+ {"FFA_RXTX_UNMAP_32 check", FFA_RXTX_UNMAP, FFA_ERROR},
+ {"FFA_PARTITION_INFO_GET_32 check", FFA_PARTITION_INFO_GET, FFA_SUCCESS_SMC32},
+ {"FFA_ID_GET_32 check", FFA_ID_GET, FFA_SUCCESS_SMC32},
+ {"FFA_MSG_POLL_32 check", FFA_MSG_POLL, FFA_SUCCESS_SMC32},
+ {"FFA_MSG_WAIT_32 check", FFA_MSG_WAIT, FFA_SUCCESS_SMC32},
+ {"FFA_YIELD_32 check", FFA_MSG_YIELD, FFA_SUCCESS_SMC32},
+ {"FFA_RUN_32 check", FFA_MSG_RUN, FFA_SUCCESS_SMC32},
+ {"FFA_MSG_SEND_32 check", FFA_MSG_SEND, FFA_SUCCESS_SMC32},
+ {"FFA_MEM_DONATE_32 check", FFA_MEM_DONATE_SMC32, FFA_SUCCESS_SMC32},
+ {"FFA_MEM_LEND_32 check", FFA_MEM_LEND_SMC32, FFA_SUCCESS_SMC32},
+ {"FFA_MEM_SHARE_32 check", FFA_MEM_SHARE_SMC32, FFA_SUCCESS_SMC32},
+ {"FFA_MEM_RETRIEVE_REQ_32 check", FFA_MEM_RETRIEVE_REQ_SMC32, FFA_SUCCESS_SMC32},
+ {"FFA_MEM_RETRIEVE_RESP_32 check", FFA_MEM_RETRIEVE_RESP, FFA_SUCCESS_SMC32},
+ {"FFA_MEM_RELINQUISH_32 check", FFA_MEM_RELINQUISH, FFA_SUCCESS_SMC32},
+ {"FFA_MEM_RECLAIM_32 check", FFA_MEM_RECLAIM, FFA_SUCCESS_SMC32},
+ {"Check non-existent command", 0xFFFF, FFA_ERROR}
+};
+
+/*
+ * Populates test_target with content of ffa_feature_test_target.
+ *
+ * Returns number of elements in the *test_target.
+ */
+unsigned int get_ffa_feature_test_target(
+ const struct ffa_features_test **test_target)
+{
+ if (test_target != NULL) {
+ *test_target = ffa_feature_test_target;
+ }
+
+ return sizeof(ffa_feature_test_target) /
+ sizeof(struct ffa_features_test);
+}
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c b/tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c
index 6e79a881..3bdacda9 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c
@@ -1,17 +1,17 @@
/*
- * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <debug.h>
+#include <smccc.h>
+
#include <arch_helpers.h>
#include <cactus_test_cmds.h>
-#include <debug.h>
#include <ffa_endpoints.h>
-#include <platform.h>
-#include <smccc.h>
-#include <ffa_helpers.h>
#include <ffa_svc.h>
+#include <platform.h>
#include <test_helpers.h>
#define ECHO_VAL1 U(0xa0a0a0a0)
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_features.c b/tftf/tests/runtime_services/secure_service/test_ffa_features.c
index 7d67bf8e..beee5d23 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_features.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_features.c
@@ -1,46 +1,13 @@
/*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <ffa_helpers.h>
+#include <spm_common.h>
#include <test_helpers.h>
#include <tftf_lib.h>
-struct feature_test {
- const char *test_name;
- unsigned int feature;
- u_register_t expected_ret;
-};
-
-static const struct feature_test test_target[] = {
- {"FFA_ERROR_32 check", FFA_ERROR, FFA_SUCCESS_SMC32},
- {"FFA_SUCCESS_32 check", FFA_SUCCESS_SMC32, FFA_SUCCESS_SMC32},
- {"FFA_INTERRUPT_32 check", FFA_INTERRUPT, FFA_SUCCESS_SMC32},
- {"FFA_VERSION_32 check", FFA_VERSION, FFA_SUCCESS_SMC32},
- {"FFA_FEATURES_32 check", FFA_FEATURES, FFA_SUCCESS_SMC32},
- {"FFA_RX_RELEASE_32 check", FFA_RX_RELEASE, FFA_SUCCESS_SMC32},
- {"FFA_RXTX_MAP_32 check", FFA_RXTX_MAP_SMC32, FFA_ERROR},
- {"FFA_RXTX_MAP_64 check", FFA_RXTX_MAP_SMC64, FFA_SUCCESS_SMC32},
- {"FFA_RXTX_UNMAP_32 check", FFA_RXTX_UNMAP, FFA_ERROR},
- {"FFA_PARTITION_INFO_GET_32 check", FFA_PARTITION_INFO_GET, FFA_SUCCESS_SMC32},
- {"FFA_ID_GET_32 check", FFA_ID_GET, FFA_SUCCESS_SMC32},
- {"FFA_MSG_POLL_32 check", FFA_MSG_POLL, FFA_SUCCESS_SMC32},
- {"FFA_MSG_WAIT_32 check", FFA_MSG_WAIT, FFA_SUCCESS_SMC32},
- {"FFA_YIELD_32 check", FFA_MSG_YIELD, FFA_SUCCESS_SMC32},
- {"FFA_RUN_32 check", FFA_MSG_RUN, FFA_SUCCESS_SMC32},
- {"FFA_MSG_SEND_32 check", FFA_MSG_SEND, FFA_SUCCESS_SMC32},
- {"FFA_MEM_DONATE_32 check", FFA_MEM_DONATE_SMC32, FFA_SUCCESS_SMC32},
- {"FFA_MEM_LEND_32 check", FFA_MEM_LEND_SMC32, FFA_SUCCESS_SMC32},
- {"FFA_MEM_SHARE_32 check", FFA_MEM_SHARE_SMC32, FFA_SUCCESS_SMC32},
- {"FFA_MEM_RETRIEVE_REQ_32 check", FFA_MEM_RETRIEVE_REQ_SMC32, FFA_SUCCESS_SMC32},
- {"FFA_MEM_RETRIEVE_RESP_32 check", FFA_MEM_RETRIEVE_RESP, FFA_SUCCESS_SMC32},
- {"FFA_MEM_RELINQUISH_32 check", FFA_MEM_RELINQUISH, FFA_SUCCESS_SMC32},
- {"FFA_MEM_RECLAIM_32 check", FFA_MEM_RECLAIM, FFA_SUCCESS_SMC32},
- {"Check non-existent command", 0xFFFF, FFA_ERROR}
-};
-
test_result_t test_ffa_features(void)
{
SKIP_TEST_IF_FFA_VERSION_LESS_THAN(1, 0);
@@ -52,23 +19,24 @@ test_result_t test_ffa_features(void)
}
smc_ret_values ffa_ret;
+ const struct ffa_features_test *ffa_feature_test_target;
unsigned int i, test_target_size =
- sizeof(test_target) / sizeof(struct feature_test);
+ get_ffa_feature_test_target(&ffa_feature_test_target);
for (i = 0U; i < test_target_size; i++) {
- ffa_ret = ffa_features(test_target[i].feature);
- if (ffa_ret.ret0 != test_target[i].expected_ret) {
- tftf_testcase_printf("%s returned %lx, expected %lx\n",
- test_target[i].test_name,
+ ffa_ret = ffa_features(ffa_feature_test_target[i].feature);
+ if (ffa_ret.ret0 != ffa_feature_test_target[i].expected_ret) {
+ tftf_testcase_printf("%s returned %lx, expected %x\n",
+ ffa_feature_test_target[i].test_name,
ffa_ret.ret0,
- test_target[i].expected_ret);
+ ffa_feature_test_target[i].expected_ret);
return TEST_RESULT_FAIL;
}
- if ((test_target[i].expected_ret == (u_register_t)FFA_ERROR) &&
+ if ((ffa_feature_test_target[i].expected_ret == (u_register_t)FFA_ERROR) &&
(ffa_ret.ret2 != (u_register_t)FFA_ERROR_NOT_SUPPORTED)) {
tftf_testcase_printf("%s failed for the wrong reason: "
"returned %lx, expected %lx\n",
- test_target[i].test_name,
+ ffa_feature_test_target[i].test_name,
ffa_ret.ret2,
(u_register_t)FFA_ERROR_NOT_SUPPORTED);
return TEST_RESULT_FAIL;
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 b861d09e..5b59c439 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
@@ -1,13 +1,13 @@
/*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <cactus_test_cmds.h>
#include <debug.h>
+
+#include <cactus_test_cmds.h>
#include <ffa_endpoints.h>
-#include <ffa_helpers.h>
#include <test_helpers.h>
#include <tftf_lib.h>
#include <xlat_tables_defs.h>
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c b/tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c
index 5251dc40..1e4c4e06 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <debug.h>
-#include <ffa_helpers.h>
+
#include <test_helpers.h>
#include <xlat_tables_defs.h>
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_version.c b/tftf/tests/runtime_services/secure_service/test_ffa_version.c
index fae058da..41eca5ad 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_version.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_version.c
@@ -1,10 +1,9 @@
/*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <ffa_helpers.h>
#include <ffa_svc.h>
#include <test_helpers.h>
#include <tftf_lib.h>
diff --git a/tftf/tests/tests-spm.mk b/tftf/tests/tests-spm.mk
index c6b304ad..2a949839 100644
--- a/tftf/tests/tests-spm.mk
+++ b/tftf/tests/tests-spm.mk
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2018-2021, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -7,9 +7,10 @@
TESTS_SOURCES += \
$(addprefix tftf/tests/runtime_services/secure_service/, \
ffa_helpers.c \
+ spm_common.c \
test_ffa_direct_messaging.c \
- test_ffa_version.c \
test_ffa_features.c \
test_ffa_memory_sharing.c \
test_ffa_rxtx_map.c \
+ test_ffa_version.c \
)