SPM: PSA API working under Thread mode when level 1
This patch redirects PSA API into a customized 'thread call' ABI to
make it execute in thread mode, when:
- Runtime backend IPC and Isolation Level 1.
This 'thread call' ABI happens in 'Thread mode', and:
- Switch to SPM stack after PSA APIs are called. The working stack
re-uses the NS Agent stack to save runtime memory or allocated a
dedicated stack for it if no Trustzone NS Agent is available. No
need to make SPM working under 'Handler mode' in this case.
- Lock scheduler to ensure PSA API context is not nested because of
scheduling. The locking is performed by setting a flag, and the
scheduler entry checks this flag to decide schedule or not.
- When PSA API returns, switch back to the caller stack. And trigger
scheduler in the caller stack if a scheduling is expected. This
helps the scheduler context management.
- SPM functionalities other than PSA API are still using SVC-based
implementation, such as SPM initialization and log info flushing.
The content of this patch:
- Define interfaces, ABI dispatcher and architecture modifications
to support handling PSA API under thread mode.
- Related header file and source path adjustment to help the build pass.
- Adjust IDLE partition stack size to make runtime execution work, the
original size is too compact to run under debug build of specific
platforms.
Change-Id: I52add3f57ef0f958d25725efb4eb702617586907
Signed-off-by: Ken Liu <Ken.Liu@arm.com>
Co-authored-by: Mingyang Sun <Mingyang.Sun@arm.com>
diff --git a/secure_fw/CMakeLists.txt b/secure_fw/CMakeLists.txt
index e43e31f..982bea8 100644
--- a/secure_fw/CMakeLists.txt
+++ b/secure_fw/CMakeLists.txt
@@ -93,6 +93,7 @@
set_source_files_properties(
${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_svc.c
+ ${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_thread.c
PROPERTIES
COMPILE_FLAGS $<$<C_COMPILER_ID:GNU>:-Wno-unused-parameter>
COMPILE_FLAGS $<$<C_COMPILER_ID:ARMClang>:-Wno-unused-parameter>
@@ -103,6 +104,7 @@
target_sources(tfm_secure_api
INTERFACE
$<$<BOOL:${TFM_PSA_API}>:${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_svc.c>
+ $<$<BOOL:${TFM_PSA_API}>:${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_thread.c>
)
target_compile_definitions(tfm_secure_api