diff options
author | Jens Wiklander <jens.wiklander@linaro.org> | 2020-08-17 10:10:44 +0200 |
---|---|---|
committer | Jérôme Forissier <jerome@forissier.org> | 2020-08-18 20:51:42 +0200 |
commit | 1a7d8eae372f72e36f4d08674f09fe72c4f64d6a (patch) | |
tree | 050847a3d42f307a64e2fa513e0108c822afc91f /core/tee | |
parent | 64df747c184edb5e6266f214eab7551798255d20 (diff) |
core: add user parameter thread_rpc_shm_cache_alloc()
Adds a user parameter to thread_rpc_shm_cache_alloc() to make sure that
different callers of thread_rpc_shm_cache_alloc() doesn't interfere with
each other. The FS allocation could perhaps be intertwined with I2C
allocations if crypto operations are done over I2C.
Fixes: 9bee8f2a5af7 ("core: add generic rpc shared memory buffer caching")
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'core/tee')
-rw-r--r-- | core/tee/socket.c | 12 | ||||
-rw-r--r-- | core/tee/tadb.c | 6 | ||||
-rw-r--r-- | core/tee/tee_fs_rpc.c | 27 |
3 files changed, 30 insertions, 15 deletions
diff --git a/core/tee/socket.c b/core/tee/socket.c index 40eedb11..94b3416b 100644 --- a/core/tee/socket.c +++ b/core/tee/socket.c @@ -33,7 +33,8 @@ static TEE_Result socket_open(uint32_t instance_id, uint32_t param_types, return TEE_ERROR_BAD_PARAMETERS; } - va = thread_rpc_shm_cache_alloc(THREAD_SHM_TYPE_APPLICATION, + va = thread_rpc_shm_cache_alloc(THREAD_SHM_CACHE_USER_SOCKET, + THREAD_SHM_TYPE_APPLICATION, params[1].memref.size, &mobj); if (!va) return TEE_ERROR_OUT_OF_MEMORY; @@ -96,7 +97,8 @@ static TEE_Result socket_send(uint32_t instance_id, uint32_t param_types, return TEE_ERROR_BAD_PARAMETERS; } - va = thread_rpc_shm_cache_alloc(THREAD_SHM_TYPE_APPLICATION, + va = thread_rpc_shm_cache_alloc(THREAD_SHM_CACHE_USER_SOCKET, + THREAD_SHM_TYPE_APPLICATION, params[1].memref.size, &mobj); if (!va) return TEE_ERROR_OUT_OF_MEMORY; @@ -134,7 +136,8 @@ static TEE_Result socket_recv(uint32_t instance_id, uint32_t param_types, return TEE_ERROR_BAD_PARAMETERS; } - va = thread_rpc_shm_cache_alloc(THREAD_SHM_TYPE_APPLICATION, + va = thread_rpc_shm_cache_alloc(THREAD_SHM_CACHE_USER_SOCKET, + THREAD_SHM_TYPE_APPLICATION, params[1].memref.size, &mobj); if (!va) return TEE_ERROR_OUT_OF_MEMORY; @@ -175,7 +178,8 @@ static TEE_Result socket_ioctl(uint32_t instance_id, uint32_t param_types, return TEE_ERROR_BAD_PARAMETERS; } - va = thread_rpc_shm_cache_alloc(THREAD_SHM_TYPE_APPLICATION, + va = thread_rpc_shm_cache_alloc(THREAD_SHM_CACHE_USER_SOCKET, + THREAD_SHM_TYPE_APPLICATION, params[1].memref.size, &mobj); if (!va) return TEE_ERROR_OUT_OF_MEMORY; diff --git a/core/tee/tadb.c b/core/tee/tadb.c index d78c90b1..28af5ce3 100644 --- a/core/tee/tadb.c +++ b/core/tee/tadb.c @@ -97,7 +97,8 @@ static TEE_Result ta_operation_open(unsigned int cmd, uint32_t file_number, TEE_Result res; void *va; - va = thread_rpc_shm_cache_alloc(THREAD_SHM_TYPE_APPLICATION, + va = thread_rpc_shm_cache_alloc(THREAD_SHM_CACHE_USER_FS, + THREAD_SHM_TYPE_APPLICATION, TEE_FS_NAME_MAX, &mobj); if (!va) return TEE_ERROR_OUT_OF_MEMORY; @@ -122,7 +123,8 @@ static TEE_Result ta_operation_remove(uint32_t file_number) struct mobj *mobj; void *va; - va = thread_rpc_shm_cache_alloc(THREAD_SHM_TYPE_APPLICATION, + va = thread_rpc_shm_cache_alloc(THREAD_SHM_CACHE_USER_FS, + THREAD_SHM_TYPE_APPLICATION, TEE_FS_NAME_MAX, &mobj); if (!va) return TEE_ERROR_OUT_OF_MEMORY; diff --git a/core/tee/tee_fs_rpc.c b/core/tee/tee_fs_rpc.c index 22891694..cceade0e 100644 --- a/core/tee/tee_fs_rpc.c +++ b/core/tee/tee_fs_rpc.c @@ -35,7 +35,8 @@ static TEE_Result operation_open(uint32_t id, unsigned int cmd, TEE_Result res; void *va; - va = thread_rpc_shm_cache_alloc(THREAD_SHM_TYPE_APPLICATION, + va = thread_rpc_shm_cache_alloc(THREAD_SHM_CACHE_USER_FS, + THREAD_SHM_TYPE_APPLICATION, TEE_FS_NAME_MAX, &mobj); if (!va) return TEE_ERROR_OUT_OF_MEMORY; @@ -77,7 +78,8 @@ static TEE_Result operation_open_dfh(uint32_t id, unsigned int cmd, TEE_Result res; void *va; - va = thread_rpc_shm_cache_alloc(THREAD_SHM_TYPE_APPLICATION, + va = thread_rpc_shm_cache_alloc(THREAD_SHM_CACHE_USER_FS, + THREAD_SHM_TYPE_APPLICATION, TEE_FS_NAME_MAX, &mobj); if (!va) return TEE_ERROR_OUT_OF_MEMORY; @@ -136,7 +138,8 @@ TEE_Result tee_fs_rpc_read_init(struct tee_fs_rpc_operation *op, if (offset < 0) return TEE_ERROR_BAD_PARAMETERS; - va = thread_rpc_shm_cache_alloc(THREAD_SHM_TYPE_APPLICATION, + va = thread_rpc_shm_cache_alloc(THREAD_SHM_CACHE_USER_FS, + THREAD_SHM_TYPE_APPLICATION, data_len, &mobj); if (!va) return TEE_ERROR_OUT_OF_MEMORY; @@ -174,7 +177,8 @@ TEE_Result tee_fs_rpc_write_init(struct tee_fs_rpc_operation *op, if (offset < 0) return TEE_ERROR_BAD_PARAMETERS; - va = thread_rpc_shm_cache_alloc(THREAD_SHM_TYPE_APPLICATION, + va = thread_rpc_shm_cache_alloc(THREAD_SHM_CACHE_USER_FS, + THREAD_SHM_TYPE_APPLICATION, data_len, &mobj); if (!va) return TEE_ERROR_OUT_OF_MEMORY; @@ -215,7 +219,8 @@ TEE_Result tee_fs_rpc_remove(uint32_t id, struct tee_pobj *po) struct mobj *mobj; void *va; - va = thread_rpc_shm_cache_alloc(THREAD_SHM_TYPE_APPLICATION, + va = thread_rpc_shm_cache_alloc(THREAD_SHM_CACHE_USER_FS, + THREAD_SHM_TYPE_APPLICATION, TEE_FS_NAME_MAX, &mobj); if (!va) return TEE_ERROR_OUT_OF_MEMORY; @@ -242,7 +247,8 @@ TEE_Result tee_fs_rpc_remove_dfh(uint32_t id, struct mobj *mobj; void *va; - va = thread_rpc_shm_cache_alloc(THREAD_SHM_TYPE_APPLICATION, + va = thread_rpc_shm_cache_alloc(THREAD_SHM_CACHE_USER_FS, + THREAD_SHM_TYPE_APPLICATION, TEE_FS_NAME_MAX, &mobj); if (!va) return TEE_ERROR_OUT_OF_MEMORY; @@ -270,7 +276,8 @@ TEE_Result tee_fs_rpc_rename(uint32_t id, struct tee_pobj *old, char *va; bool temp; - va = thread_rpc_shm_cache_alloc(THREAD_SHM_TYPE_APPLICATION, + va = thread_rpc_shm_cache_alloc(THREAD_SHM_CACHE_USER_FS, + THREAD_SHM_TYPE_APPLICATION, TEE_FS_NAME_MAX * 2, &mobj); if (!va) return TEE_ERROR_OUT_OF_MEMORY; @@ -321,7 +328,8 @@ TEE_Result tee_fs_rpc_opendir(uint32_t id, const TEE_UUID *uuid, if (!dir) return TEE_ERROR_OUT_OF_MEMORY; - va = thread_rpc_shm_cache_alloc(THREAD_SHM_TYPE_APPLICATION, + va = thread_rpc_shm_cache_alloc(THREAD_SHM_CACHE_USER_FS, + THREAD_SHM_TYPE_APPLICATION, TEE_FS_NAME_MAX, &mobj); if (!va) { res = TEE_ERROR_OUT_OF_MEMORY; @@ -381,7 +389,8 @@ TEE_Result tee_fs_rpc_readdir(uint32_t id, struct tee_fs_dir *d, if (!d) return TEE_ERROR_ITEM_NOT_FOUND; - va = thread_rpc_shm_cache_alloc(THREAD_SHM_TYPE_APPLICATION, + va = thread_rpc_shm_cache_alloc(THREAD_SHM_CACHE_USER_FS, + THREAD_SHM_TYPE_APPLICATION, max_name_len, &mobj); if (!va) return TEE_ERROR_OUT_OF_MEMORY; |