Test: Trigger secure tests in SPE in IPC model
This patch enables TF-M SPE to start secure test cases in IPC model
without the routine from NS to Secure Client Service.
Signed-off-by: Jianliang Shen <jianliang.shen@arm.com>
Change-Id: I4581d3e68df48ffa23c440139c90b92576621727
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 2413e47..1c1b4e7 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -223,6 +223,7 @@
PUBLIC
$<$<BOOL:${TEST_FRAMEWORK_NS}>:TEST_FRAMEWORK_NS>
$<$<BOOL:${TEST_FRAMEWORK_S}>:TEST_FRAMEWORK_S>
+ $<$<BOOL:${TFM_LIB_MODEL}>:TFM_LIB_MODEL>
)
############################# TFM NS app #######################################
diff --git a/app/tfm_integ_test.c b/app/tfm_integ_test.c
index 041e733..3f69969 100644
--- a/app/tfm_integ_test.c
+++ b/app/tfm_integ_test.c
@@ -11,7 +11,9 @@
#include "test_framework_integ_test.h"
#endif
-#ifdef TEST_FRAMEWORK_S
+#if defined(TEST_FRAMEWORK_S) && defined(TFM_LIB_MODEL)
+/* Function tfm_secure_client_run_tests() which is declared in
+ * tfm_secure_client_service_api.h is only required in NS for Library mode. */
#include "tfm_secure_client_service_api.h"
#endif
@@ -25,7 +27,7 @@
{
UNUSED_VARIABLE(argument);
-#ifdef TEST_FRAMEWORK_S
+#if defined(TEST_FRAMEWORK_S) && defined(TFM_LIB_MODEL)
/* FIXME: The non-secure audit log test currently relies on the fact that
* the audit log secure test is run first. However the Non-secure tests
* represent simpler and more common test cases which would make more sense
diff --git a/test/config/check_config.cmake b/test/config/check_config.cmake
index 39d1346..6d3084e 100644
--- a/test/config/check_config.cmake
+++ b/test/config/check_config.cmake
@@ -49,8 +49,15 @@
tfm_invalid_config((NOT TFM_MULTI_CORE_TOPOLOGY) AND TEST_NS_MULTI_CORE)
tfm_invalid_config(TEST_NS_T_COSE AND SYMMETRIC_INITIAL_ATTESTATION)
-# So far all regression tests are triggered from NS app
-tfm_invalid_config(NOT NS)
+########################## Check Framework #####################################
+
+# In IPC model, NS regression test needs NS. Secure regression test can build
+# without NS.
+tfm_invalid_config(NOT NS AND TEST_FRAMEWORK_NS AND NOT TFM_LIB_MODEL)
+
+# In library model, when regression test(TEST_FRAMEWORK_NS or TEST_FRAMEWORK_S)
+# open, NS shall be ON.
+tfm_invalid_config(NOT NS AND (TEST_FRAMEWORK_NS OR TEST_FRAMEWORK_S) AND TFM_LIB_MODEL)
########################## Check suites dependence #############################
diff --git a/test/test_services/tfm_attest_test_service/CMakeLists.txt b/test/test_services/tfm_attest_test_service/CMakeLists.txt
index 851c95c..b140977 100644
--- a/test/test_services/tfm_attest_test_service/CMakeLists.txt
+++ b/test/test_services/tfm_attest_test_service/CMakeLists.txt
@@ -76,22 +76,24 @@
############################ NS API ############################################
-target_sources(tfm_api_ns
- PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/tfm_attest_test_service_ns_api.c
-)
+if(TEST_FRAMEWORK_NS)
+ target_sources(tfm_api_ns
+ PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}/tfm_attest_test_service_ns_api.c
+ )
-# The veneers give warnings about not being properly declared so they get hidden
-# to not overshadow _real_ warnings.
-set_source_files_properties(tfm_attest_test_service_ns_api.c
- PROPERTIES
- COMPILE_FLAGS -Wno-implicit-function-declaration
-)
+ # The veneers give warnings about not being properly declared so they get hidden
+ # to not overshadow _real_ warnings.
+ set_source_files_properties(tfm_attest_test_service_ns_api.c
+ PROPERTIES
+ COMPILE_FLAGS -Wno-implicit-function-declaration
+ )
-target_include_directories(tfm_api_ns
- PUBLIC
- .
-)
+ target_include_directories(tfm_api_ns
+ PUBLIC
+ .
+ )
+endif()
############################ Secure API ########################################
diff --git a/test/test_services/tfm_secure_client_service/CMakeLists.txt b/test/test_services/tfm_secure_client_service/CMakeLists.txt
index b0693b1..2542f5c 100644
--- a/test/test_services/tfm_secure_client_service/CMakeLists.txt
+++ b/test/test_services/tfm_secure_client_service/CMakeLists.txt
@@ -56,22 +56,27 @@
############################ NS API ############################################
-target_sources(tfm_api_ns
- PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/tfm_secure_client_service_api.c
-)
+# As secure regression tests can run without non-secure client trigger in IPC
+# model now, function tfm_secure_client_service_api.c will be used only in
+# library model
+if(NS AND TFM_LIB_MODEL)
+ target_sources(tfm_api_ns
+ PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}/tfm_secure_client_service_api.c
+ )
-# The veneers give warnings about not being properly declared so they get hidden
-# to not overshadow _real_ warnings.
-set_source_files_properties(tfm_secure_client_service_api.c
- PROPERTIES
- COMPILE_FLAGS -Wno-implicit-function-declaration
-)
+ # The veneers give warnings about not being properly declared so they get hidden
+ # to not overshadow _real_ warnings.
+ set_source_files_properties(tfm_secure_client_service_api.c
+ PROPERTIES
+ COMPILE_FLAGS -Wno-implicit-function-declaration
+ )
-target_include_directories(tfm_api_ns
- PUBLIC
- .
-)
+ target_include_directories(tfm_api_ns
+ PUBLIC
+ .
+ )
+endif()
############################ Partition Defs ####################################
diff --git a/test/test_services/tfm_secure_client_service/tfm_secure_client_service.c b/test/test_services/tfm_secure_client_service/tfm_secure_client_service.c
index eb88377..a916fcd 100644
--- a/test/test_services/tfm_secure_client_service/tfm_secure_client_service.c
+++ b/test/test_services/tfm_secure_client_service/tfm_secure_client_service.c
@@ -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
*
@@ -8,11 +8,9 @@
#include "tfm_secure_client_service.h"
#include "test_framework_integ_test.h"
#ifdef TFM_PSA_API
-#include "psa/client.h"
#include "psa/service.h"
#include "psa_manifest/tfm_secure_client_service.h"
#endif
-
/**
* \brief Service initialisation function. No special initialisation is
* required.
@@ -22,29 +20,16 @@
int32_t tfm_secure_client_service_init(void)
{
#ifdef TFM_PSA_API
- psa_msg_t msg;
+ psa_signal_t signals;
- while (1) {
- psa_wait(TFM_SECURE_CLIENT_SFN_RUN_TESTS_SIGNAL, PSA_BLOCK);
- psa_get(TFM_SECURE_CLIENT_SFN_RUN_TESTS_SIGNAL, &msg);
- switch (msg.type) {
- case PSA_IPC_CONNECT:
- psa_reply(msg.handle, PSA_SUCCESS);
- break;
- case PSA_IPC_CALL:
- psa_reply(msg.handle, tfm_secure_client_service_sfn_run_tests());
- break;
- case PSA_IPC_DISCONNECT:
- psa_reply(msg.handle, PSA_SUCCESS);
- break;
- default:
- /* cannot get here? [broken SPM]. TODO*/
- break;
- }
+ tfm_secure_client_service_sfn_run_tests();
+
+ signals = psa_wait(PSA_WAIT_ANY, PSA_BLOCK);
+ if (signals & TFM_SECURE_CLIENT_SRV_DUMMY_SIGNAL) {
+ psa_panic();
}
-#else
- return 0;
#endif
+ return 0;
}
int32_t tfm_secure_client_service_sfn_run_tests(void)
diff --git a/test/test_services/tfm_secure_client_service/tfm_secure_client_service.yaml b/test/test_services/tfm_secure_client_service/tfm_secure_client_service.yaml
index 7d0e1c1..cdc4dcb 100644
--- a/test/test_services/tfm_secure_client_service/tfm_secure_client_service.yaml
+++ b/test/test_services/tfm_secure_client_service/tfm_secure_client_service.yaml
@@ -9,7 +9,7 @@
"psa_framework_version": 1.0,
"name": "TFM_SP_SECURE_TEST_PARTITION",
"type": "PSA-ROT",
- "priority": "NORMAL",
+ "priority": "LOW",
"entry_point": "tfm_secure_client_service_init",
"stack_size": "0x0D00",
"mmio_regions": [
@@ -29,9 +29,9 @@
],
"services": [
{
- "name": "TFM_SECURE_CLIENT_SFN_RUN_TESTS",
+ "name": "TFM_SECURE_CLIENT_SRV_DUMMY",
"sid": "0x0000F000",
- "non_secure_clients": true,
+ "non_secure_clients": false,
"version": 1,
"version_policy": "STRICT"
}
diff --git a/test/test_services/tfm_secure_client_service/tfm_secure_client_service_api.c b/test/test_services/tfm_secure_client_service/tfm_secure_client_service_api.c
index 417dafa..6e1eb52 100644
--- a/test/test_services/tfm_secure_client_service/tfm_secure_client_service_api.c
+++ b/test/test_services/tfm_secure_client_service/tfm_secure_client_service_api.c
@@ -6,33 +6,11 @@
*/
#include "tfm_secure_client_service_api.h"
-#ifdef TFM_PSA_API
-#include "psa/client.h"
-#include "tfm_api.h"
-#include "psa_manifest/sid.h"
-#else /* TFM_PSA_API */
#include "tfm_veneers.h"
-#endif /* TFM_PSA_API */
int32_t tfm_secure_client_run_tests(void)
{
-#ifdef TFM_PSA_API
- psa_handle_t handle;
- psa_status_t status;
-
- handle = psa_connect(TFM_SECURE_CLIENT_SFN_RUN_TESTS_SID,
- TFM_SECURE_CLIENT_SFN_RUN_TESTS_VERSION);
- if (handle <= 0) {
- return TFM_ERROR_GENERIC;
- }
-
- status = psa_call(handle, PSA_IPC_CALL, NULL, 0, NULL, 0);
- psa_close(handle);
-
- if (status != PSA_SUCCESS) {
- return TFM_ERROR_GENERIC;
- }
-#else
+#ifndef TFM_PSA_API
tfm_secure_client_service_sfn_run_tests_veneer(NULL, 0, NULL, 0);
#endif