aboutsummaryrefslogtreecommitdiff
path: root/tftf
diff options
context:
space:
mode:
authorJ-Alves <joao.alves@arm.com>2020-05-26 17:14:40 +0100
committerJ-Alves <joao.alves@arm.com>2020-06-19 09:34:30 +0100
commit8f08a05490ed3ce474cc821297929bf8df5691d2 (patch)
treeda0afb6bc23221c8fd9efe95b6fdc559245a7987 /tftf
parent87c9a5cc97c16f6c1c991fab334bfed4e4fce296 (diff)
downloadtf-a-tests-8f08a05490ed3ce474cc821297929bf8df5691d2.tar.gz
SPM: TFTF test of FFA_VERSION interface
Implemented test to FFA_VERSION interface: - "test_ffa_version.c" contains functions to test FFA_VERSION ABI; - Test suite for FFA_VERSION ABI in tests-spm.xml; - Helper macros changed in "ffa_helpers.h". Signed-off-by: J-Alves <joao.alves@arm.com> Change-Id: I6b0e937e30fceaa21a57c4ba0761a62049b16c0d
Diffstat (limited to 'tftf')
-rw-r--r--tftf/tests/runtime_services/secure_service/ffa_helpers.c11
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_version.c89
-rw-r--r--tftf/tests/tests-spm.mk1
-rw-r--r--tftf/tests/tests-spm.xml18
4 files changed, 117 insertions, 2 deletions
diff --git a/tftf/tests/runtime_services/secure_service/ffa_helpers.c b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
index 9d19fec2..ba57cfec 100644
--- a/tftf/tests/runtime_services/secure_service/ffa_helpers.c
+++ b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
@@ -106,3 +106,14 @@ smc_ret_values ffa_msg_send_direct_req64(uint32_t source_id, uint32_t dest_id,
return __ffa_msg_send_direct_req64_5(source_id, dest_id,
message, 0, 0, 0, 0);
}
+
+/* FFA Version ABI helper */
+smc_ret_values ffa_version(uint32_t input_version)
+{
+ smc_args args = {
+ .fid = FFA_VERSION,
+ .arg1 = input_version
+ };
+
+ return tftf_smc(&args);
+}
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_version.c b/tftf/tests/runtime_services/secure_service/test_ffa_version.c
new file mode 100644
index 00000000..fae058da
--- /dev/null
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_version.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2020, 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>
+
+/*
+ * Using FFA version expected for SPM.
+ */
+#define SPM_VERSION MAKE_FFA_VERSION(FFA_VERSION_MAJOR, FFA_VERSION_MINOR)
+
+static bool should_skip_test;
+
+/*
+ * Calls FFA Version ABI, and checks if the result as expected.
+ */
+static test_result_t test_ffa_version(uint32_t input_version, uint32_t expected_return)
+{
+ if (should_skip_test) {
+ return TEST_RESULT_SKIPPED;
+ }
+
+ smc_ret_values ret_values = ffa_version(input_version);
+
+ uint32_t spm_version = (uint32_t)(0xFFFFFFFF & ret_values.ret0);
+
+ if (spm_version == expected_return) {
+ return TEST_RESULT_SUCCESS;
+ }
+
+ tftf_testcase_printf("Input Version: 0x%x\nReturn: 0x%x\nExpected: 0x%x\n",
+ input_version, spm_version, expected_return);
+
+ return TEST_RESULT_FAIL;
+}
+
+/*
+ * @Test_Aim@ Validate what happens when using same version as SPM.
+ */
+test_result_t test_ffa_version_equal(void)
+{
+ /*
+ * FFA_VERSION interface is used to check that SPM functionality is supported.
+ * On FFA_VERSION invocation from TFTF, the SPMD returns either NOT_SUPPORTED or
+ * the SPMC version value provided in the SPMC manifest. The variable "should_skip_test"
+ * is set to true when the SPMD returns NOT_SUPPORTED or a mismatched version, which
+ * means that a TFTF physical FF-A endpoint version (SPM_VERSION) does not match the
+ * SPMC's physical FF-A endpoint version. This prevents running the subsequent FF-A
+ * version tests (and break the test flow), as they're not relevant when the SPMD is
+ * not present within BL31 (FFA_VERSION returns NOT_SUPPORTED).
+ */
+ test_result_t ret = test_ffa_version(SPM_VERSION, SPM_VERSION);
+ if (ret != TEST_RESULT_SUCCESS) {
+ should_skip_test = true;
+ ret = TEST_RESULT_SKIPPED;
+ }
+ return ret;
+}
+
+/*
+ * @Test_Aim@ Validate what happens when setting bit 31 in
+ * 'input_version'. As per spec, FFA version is 31 bits long.
+ * Bit 31 set is an invalid input.
+ */
+test_result_t test_ffa_version_bit31(void)
+{
+ return test_ffa_version(FFA_VERSION_BIT31_MASK | SPM_VERSION, FFA_ERROR_NOT_SUPPORTED);
+}
+
+/*
+ * @Test_Aim@ Validate what happens for bigger version than SPM's.
+ */
+test_result_t test_ffa_version_bigger(void)
+{
+ return test_ffa_version(MAKE_FFA_VERSION(FFA_VERSION_MAJOR + 1, 0), SPM_VERSION);
+}
+
+/*
+ * @Test_Aim@ Validate what happens for smaller version than SPM's.
+ */
+test_result_t test_ffa_version_smaller(void)
+{
+ return test_ffa_version(MAKE_FFA_VERSION(0, 9), SPM_VERSION);
+}
diff --git a/tftf/tests/tests-spm.mk b/tftf/tests/tests-spm.mk
index dab4c6ac..0c54e1c9 100644
--- a/tftf/tests/tests-spm.mk
+++ b/tftf/tests/tests-spm.mk
@@ -8,4 +8,5 @@ TESTS_SOURCES += \
$(addprefix tftf/tests/runtime_services/secure_service/, \
ffa_helpers.c \
test_ffa_direct_messaging.c \
+ test_ffa_version.c \
)
diff --git a/tftf/tests/tests-spm.xml b/tftf/tests/tests-spm.xml
index 09af6397..5ed25247 100644
--- a/tftf/tests/tests-spm.xml
+++ b/tftf/tests/tests-spm.xml
@@ -8,8 +8,22 @@
<testsuites>
- <testsuite name="Secure Partition Manager"
- description="Test SPM APIs">
+ <testsuite name="PSA FF-A Version"
+ description="Test PSA FF-A Version ABI" >
+
+ <testcase name="Same FFA version as SPM"
+ function="test_ffa_version_equal" />
+ <testcase name="Setting bit 31 in input version"
+ function="test_ffa_version_bit31"/>
+ <testcase name="Bigger FFA version than SPM"
+ function="test_ffa_version_bigger" />
+ <testcase name="Smaller FFA version than SPM"
+ function="test_ffa_version_smaller" />
+
+ </testsuite>
+
+ <testsuite name="PSA FF-A Direct messaging"
+ description="Test PSA FF-A Direct messaging ABI" >
<testcase name="PSA FF-A direct messaging API"
function="test_ffa_direct_messaging" />