diff options
author | Mingyang Sun <mingyang.sun@arm.com> | 2021-03-04 13:41:56 +0800 |
---|---|---|
committer | Ken Liu <ken.liu@arm.com> | 2021-03-22 03:06:30 +0100 |
commit | 00cef5edfe54c9e113c2b636451d0ebfe600142d (patch) | |
tree | c8e4ccb31730752cd55208fe5e9578b15c0c8082 | |
parent | e00c39cad559abadabe97496694117095fba4907 (diff) | |
download | trusted-firmware-m-00cef5edfe54c9e113c2b636451d0ebfe600142d.tar.gz |
SPM: Client API change for stateless service
Calling psa_connect() or psa_close() to a stateless
service is a PROGRAMMAR ERROR.
Add a macro IS_STATIC_HANDLE() to check if a handle
is stateless.
Change-Id: I35da255da9ceda7de5597f695011b326f6fcc8a7
Signed-off-by: Mingyang Sun <mingyang.sun@arm.com>
-rw-r--r-- | secure_fw/spm/cmsis_psa/spm_ipc.h | 2 | ||||
-rw-r--r-- | secure_fw/spm/ffm/spm_psa_client_call.c | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.h b/secure_fw/spm/cmsis_psa/spm_ipc.h index 6aa0842778..dd029115e1 100644 --- a/secure_fw/spm/cmsis_psa/spm_ipc.h +++ b/secure_fw/spm/cmsis_psa/spm_ipc.h @@ -32,6 +32,8 @@ /* Set a minimum for client handle. Reserve small values for static handle. */ #define STATIC_HANDLE_VALUE_LIMIT 32 #define CLIENT_HANDLE_VALUE_MIN (STATIC_HANDLE_VALUE_LIMIT + 1) +#define IS_STATIC_HANDLE(h) ((h) > 0 && \ + (h) <= STATIC_HANDLE_VALUE_LIMIT) #define SPM_INVALID_PARTITION_IDX (~0U) diff --git a/secure_fw/spm/ffm/spm_psa_client_call.c b/secure_fw/spm/ffm/spm_psa_client_call.c index 98a695fb94..a51d54f2c8 100644 --- a/secure_fw/spm/ffm/spm_psa_client_call.c +++ b/secure_fw/spm/ffm/spm_psa_client_call.c @@ -78,6 +78,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->service_db->connection_based) { + TFM_PROGRAMMER_ERROR(ns_caller, PSA_ERROR_PROGRAMMER_ERROR); + } + if (ns_caller) { client_id = tfm_nspm_get_current_client_id(); } else { @@ -266,6 +271,11 @@ void tfm_spm_client_psa_close(psa_handle_t handle, bool ns_caller) return; } + /* It is a PROGRAMMER ERROR if called with a stateless handle. */ + if (IS_STATIC_HANDLE(handle)) { + TFM_PROGRAMMER_ERROR(ns_caller, PROGRAMMER_ERROR_NULL); + } + if (ns_caller) { client_id = tfm_nspm_get_current_client_id(); } else { |