aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMingyang Sun <mingyang.sun@arm.com>2021-06-11 15:07:58 +0800
committerMingyang Sun <mingyang.sun@arm.com>2021-06-15 17:44:23 +0800
commitef42f444063280f217cc4bcfc4fb43bfa4df8932 (patch)
treef2543992bffc82c9c651eb78c2e086213de0e08c
parent294ce2e55dfa9794f3d905a300200d9584ca8969 (diff)
downloadtrusted-firmware-m-ef42f444063280f217cc4bcfc4fb43bfa4df8932.tar.gz
SPM: Stateless services can be searched by sid
Stateless services need to be able to be found by SID. This is required in 'psa_connect()' and 'psa_version()' API. Error check order in 'psa_connect()' is also updated: If a stateless service SID is detected, block the connection directly. Change-Id: If5182d72986173eb33ff1af99dff79cb3661f0fe Signed-off-by: Mingyang Sun <mingyang.sun@arm.com>
-rw-r--r--secure_fw/spm/cmsis_psa/spm_ipc.c7
-rw-r--r--secure_fw/spm/ffm/spm_psa_client_call.c10
2 files changed, 12 insertions, 5 deletions
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c
index 02fa3dcee4..c633256b71 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.c
@@ -322,8 +322,15 @@ uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_flags)
struct service_t *tfm_spm_get_service_by_sid(uint32_t sid)
{
+ uint32_t i = 0;
struct service_t *p_serv = connection_services_listhead;
+ for (i = 0; i < STATIC_HANDLE_NUM_LIMIT; i++) {
+ if (stateless_services_ref_tbl[i]->p_ldinf->sid == sid) {
+ return stateless_services_ref_tbl[i];
+ }
+ }
+
while (p_serv && p_serv->p_ldinf->sid != sid) {
p_serv = TO_CONTAINER(BI_LIST_NEXT_NODE(&p_serv->list),
struct service_t, list);
diff --git a/secure_fw/spm/ffm/spm_psa_client_call.c b/secure_fw/spm/ffm/spm_psa_client_call.c
index 60be138afe..8eaf3e51ce 100644
--- a/secure_fw/spm/ffm/spm_psa_client_call.c
+++ b/secure_fw/spm/ffm/spm_psa_client_call.c
@@ -66,6 +66,11 @@ psa_status_t tfm_spm_client_psa_connect(uint32_t sid, uint32_t version,
TFM_PROGRAMMER_ERROR(ns_caller, PSA_ERROR_CONNECTION_REFUSED);
}
+ /* It is a PROGRAMMER ERROR if connecting to a stateless service. */
+ if (SERVICE_IS_STATELESS(service->p_ldinf->flags)) {
+ TFM_PROGRAMMER_ERROR(ns_caller, PSA_ERROR_PROGRAMMER_ERROR);
+ }
+
/*
* It is a PROGRAMMER ERROR if the caller is not authorized to access the
* RoT Service.
@@ -82,11 +87,6 @@ psa_status_t tfm_spm_client_psa_connect(uint32_t sid, uint32_t version,
TFM_PROGRAMMER_ERROR(ns_caller, PSA_ERROR_CONNECTION_REFUSED);
}
- /* It is a PROGRAMMER ERROR if connecting to a stateless service. */
- if (SERVICE_IS_STATELESS(service->p_ldinf->flags)) {
- TFM_PROGRAMMER_ERROR(ns_caller, PSA_ERROR_PROGRAMMER_ERROR);
- }
-
if (ns_caller) {
client_id = tfm_nspm_get_current_client_id();
} else {