aboutsummaryrefslogtreecommitdiff
path: root/core/tee
diff options
context:
space:
mode:
authorJens Wiklander <jens.wiklander@linaro.org>2018-10-22 22:18:18 +0200
committerJérôme Forissier <jerome.forissier@linaro.org>2018-11-15 11:42:52 +0100
commitf4feeeeffd7a608eb09ae34c3164506c5c3f4483 (patch)
tree58cda2f453db073ccf27ddb76c9b3101f935d129 /core/tee
parent05aaaa3b9720a16c5f5cbe2564738be7ec95384b (diff)
core: tee_fs_rpc.c get rid of init_memparam()
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'core/tee')
-rw-r--r--core/tee/tee_fs_rpc.c179
1 files changed, 81 insertions, 98 deletions
diff --git a/core/tee/tee_fs_rpc.c b/core/tee/tee_fs_rpc.c
index e1062496..6e13eabe 100644
--- a/core/tee/tee_fs_rpc.c
+++ b/core/tee/tee_fs_rpc.c
@@ -28,17 +28,9 @@ static TEE_Result operation_commit(struct tee_fs_rpc_operation *op)
return thread_rpc_cmd(op->id, op->num_params, op->params);
}
-static void init_memparam(struct thread_param *param, struct mobj *mobj,
- size_t offs, size_t size, enum thread_param_attr attr)
-{
- *param = (struct thread_param){ .attr = attr, .u = { .memref = {
- .offs = offs, .size = size, .mobj = mobj } } };
-}
-
static TEE_Result operation_open(uint32_t id, unsigned int cmd,
struct tee_pobj *po, int *fd)
{
- struct tee_fs_rpc_operation op = { .id = id, .num_params = 3 };
struct mobj *mobj;
TEE_Result res;
void *va;
@@ -47,18 +39,17 @@ static TEE_Result operation_open(uint32_t id, unsigned int cmd,
if (!va)
return TEE_ERROR_OUT_OF_MEMORY;
- op.params[0].attr = THREAD_PARAM_ATTR_VALUE_IN;
- op.params[0].u.value.a = cmd;
-
- init_memparam(op.params + 1, mobj, 0, TEE_FS_NAME_MAX,
- THREAD_PARAM_ATTR_MEMREF_IN);
-
res = tee_svc_storage_create_filename(va, TEE_FS_NAME_MAX,
po, po->temporary);
if (res != TEE_SUCCESS)
return res;
- op.params[2].attr = THREAD_PARAM_ATTR_VALUE_OUT;
+ struct tee_fs_rpc_operation op = {
+ .id = id, .num_params = 3, .params = {
+ [0] = THREAD_PARAM_VALUE(IN, cmd, 0, 0),
+ [1] = THREAD_PARAM_MEMREF(IN, mobj, 0, TEE_FS_NAME_MAX),
+ [2] = THREAD_PARAM_VALUE(OUT, 0, 0, 0),
+ } };
res = operation_commit(&op);
if (res == TEE_SUCCESS)
@@ -81,7 +72,6 @@ static TEE_Result operation_open_dfh(uint32_t id, unsigned int cmd,
const struct tee_fs_dirfile_fileh *dfh,
int *fd)
{
- struct tee_fs_rpc_operation op = { .id = id, .num_params = 3 };
struct mobj *mobj;
TEE_Result res;
void *va;
@@ -90,17 +80,16 @@ static TEE_Result operation_open_dfh(uint32_t id, unsigned int cmd,
if (!va)
return TEE_ERROR_OUT_OF_MEMORY;
- op.params[0].attr = THREAD_PARAM_ATTR_VALUE_IN;
- op.params[0].u.value.a = cmd;
-
- init_memparam(op.params + 1, mobj, 0, TEE_FS_NAME_MAX,
- THREAD_PARAM_ATTR_MEMREF_IN);
-
res = tee_svc_storage_create_filename_dfh(va, TEE_FS_NAME_MAX, dfh);
if (res != TEE_SUCCESS)
return res;
- op.params[2].attr = THREAD_PARAM_ATTR_VALUE_OUT;
+ struct tee_fs_rpc_operation op = {
+ .id = id, .num_params = 3, .params = {
+ [0] = THREAD_PARAM_VALUE(IN, cmd, 0, 0),
+ [1] = THREAD_PARAM_MEMREF(IN, mobj, 0, TEE_FS_NAME_MAX),
+ [2] = THREAD_PARAM_VALUE(OUT, 0, 0, 0),
+ } };
res = operation_commit(&op);
if (res == TEE_SUCCESS)
@@ -126,11 +115,11 @@ TEE_Result tee_fs_rpc_create_dfh(uint32_t id,
TEE_Result tee_fs_rpc_close(uint32_t id, int fd)
{
- struct tee_fs_rpc_operation op = { .id = id, .num_params = 1 };
-
- op.params[0].attr = THREAD_PARAM_ATTR_VALUE_IN;
- op.params[0].u.value.a = OPTEE_MRF_CLOSE;
- op.params[0].u.value.b = fd;
+ struct tee_fs_rpc_operation op = {
+ .id = id, .num_params = 1, .params = {
+ [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_CLOSE, fd, 0),
+ },
+ };
return operation_commit(&op);
}
@@ -149,17 +138,13 @@ TEE_Result tee_fs_rpc_read_init(struct tee_fs_rpc_operation *op,
if (!va)
return TEE_ERROR_OUT_OF_MEMORY;
- memset(op, 0, sizeof(*op));
- op->id = id;
- op->num_params = 2;
-
- op->params[0].attr = THREAD_PARAM_ATTR_VALUE_IN;
- op->params[0].u.value.a = OPTEE_MRF_READ;
- op->params[0].u.value.b = fd;
- op->params[0].u.value.c = offset;
-
- init_memparam(op->params + 1, mobj, 0, data_len,
- THREAD_PARAM_ATTR_MEMREF_OUT);
+ *op = (struct tee_fs_rpc_operation){
+ .id = id, .num_params = 2, .params = {
+ [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_READ, fd,
+ offset),
+ [1] = THREAD_PARAM_MEMREF(OUT, mobj, 0, data_len),
+ },
+ };
*out_data = va;
@@ -190,17 +175,13 @@ TEE_Result tee_fs_rpc_write_init(struct tee_fs_rpc_operation *op,
if (!va)
return TEE_ERROR_OUT_OF_MEMORY;
- memset(op, 0, sizeof(*op));
- op->id = id;
- op->num_params = 2;
-
- op->params[0].attr = THREAD_PARAM_ATTR_VALUE_IN;
- op->params[0].u.value.a = OPTEE_MRF_WRITE;
- op->params[0].u.value.b = fd;
- op->params[0].u.value.c = offset;
-
- init_memparam(op->params + 1, mobj, 0, data_len,
- THREAD_PARAM_ATTR_MEMREF_IN);
+ *op = (struct tee_fs_rpc_operation){
+ .id = id, .num_params = 2, .params = {
+ [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_WRITE, fd,
+ offset),
+ [1] = THREAD_PARAM_MEMREF(IN, mobj, 0, data_len),
+ },
+ };
*data = va;
@@ -214,12 +195,12 @@ TEE_Result tee_fs_rpc_write_final(struct tee_fs_rpc_operation *op)
TEE_Result tee_fs_rpc_truncate(uint32_t id, int fd, size_t len)
{
- struct tee_fs_rpc_operation op = { .id = id, .num_params = 1 };
-
- op.params[0].attr = THREAD_PARAM_ATTR_VALUE_IN;
- op.params[0].u.value.a = OPTEE_MRF_TRUNCATE;
- op.params[0].u.value.b = fd;
- op.params[0].u.value.c = len;
+ struct tee_fs_rpc_operation op = {
+ .id = id, .num_params = 1, .params = {
+ [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_TRUNCATE, fd,
+ len),
+ }
+ };
return operation_commit(&op);
}
@@ -227,7 +208,6 @@ TEE_Result tee_fs_rpc_truncate(uint32_t id, int fd, size_t len)
TEE_Result tee_fs_rpc_remove(uint32_t id, struct tee_pobj *po)
{
TEE_Result res;
- struct tee_fs_rpc_operation op = { .id = id, .num_params = 2 };
struct mobj *mobj;
void *va;
@@ -235,17 +215,18 @@ TEE_Result tee_fs_rpc_remove(uint32_t id, struct tee_pobj *po)
if (!va)
return TEE_ERROR_OUT_OF_MEMORY;
- op.params[0].attr = THREAD_PARAM_ATTR_VALUE_IN;
- op.params[0].u.value.a = OPTEE_MRF_REMOVE;
-
- init_memparam(op.params + 1, mobj, 0, TEE_FS_NAME_MAX,
- THREAD_PARAM_ATTR_MEMREF_IN);
-
res = tee_svc_storage_create_filename(va, TEE_FS_NAME_MAX,
po, po->temporary);
if (res != TEE_SUCCESS)
return res;
+ struct tee_fs_rpc_operation op = {
+ .id = id, .num_params = 2, .params = {
+ [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_REMOVE, 0, 0),
+ [1] = THREAD_PARAM_MEMREF(IN, mobj, 0, TEE_FS_NAME_MAX),
+ },
+ };
+
return operation_commit(&op);
}
@@ -253,7 +234,6 @@ TEE_Result tee_fs_rpc_remove_dfh(uint32_t id,
const struct tee_fs_dirfile_fileh *dfh)
{
TEE_Result res;
- struct tee_fs_rpc_operation op = { .id = id, .num_params = 2 };
struct mobj *mobj;
void *va;
@@ -261,16 +241,18 @@ TEE_Result tee_fs_rpc_remove_dfh(uint32_t id,
if (!va)
return TEE_ERROR_OUT_OF_MEMORY;
- op.params[0].attr = THREAD_PARAM_ATTR_VALUE_IN;
- op.params[0].u.value.a = OPTEE_MRF_REMOVE;
-
- init_memparam(op.params + 1, mobj, 0, TEE_FS_NAME_MAX,
- THREAD_PARAM_ATTR_MEMREF_IN);
res = tee_svc_storage_create_filename_dfh(va, TEE_FS_NAME_MAX, dfh);
if (res != TEE_SUCCESS)
return res;
+ struct tee_fs_rpc_operation op = {
+ .id = id, .num_params = 2, .params = {
+ [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_REMOVE, 0, 0),
+ [1] = THREAD_PARAM_MEMREF(IN, mobj, 0, TEE_FS_NAME_MAX),
+ }
+ };
+
return operation_commit(&op);
}
@@ -278,7 +260,6 @@ TEE_Result tee_fs_rpc_rename(uint32_t id, struct tee_pobj *old,
struct tee_pobj *new, bool overwrite)
{
TEE_Result res;
- struct tee_fs_rpc_operation op = { .id = id, .num_params = 3 };
struct mobj *mobj;
char *va;
bool temp;
@@ -287,12 +268,6 @@ TEE_Result tee_fs_rpc_rename(uint32_t id, struct tee_pobj *old,
if (!va)
return TEE_ERROR_OUT_OF_MEMORY;
- op.params[0].attr = THREAD_PARAM_ATTR_VALUE_IN;
- op.params[0].u.value.a = OPTEE_MRF_RENAME;
- op.params[0].u.value.b = overwrite;
-
- init_memparam(op.params + 1, mobj, 0, TEE_FS_NAME_MAX,
- THREAD_PARAM_ATTR_MEMREF_IN);
if (new)
temp = old->temporary;
@@ -303,9 +278,6 @@ TEE_Result tee_fs_rpc_rename(uint32_t id, struct tee_pobj *old,
if (res != TEE_SUCCESS)
return res;
- init_memparam(op.params + 2, mobj, TEE_FS_NAME_MAX,
- TEE_FS_NAME_MAX, THREAD_PARAM_ATTR_MEMREF_IN);
-
if (new) {
res = tee_svc_storage_create_filename(va + TEE_FS_NAME_MAX,
TEE_FS_NAME_MAX,
@@ -318,6 +290,16 @@ TEE_Result tee_fs_rpc_rename(uint32_t id, struct tee_pobj *old,
if (res != TEE_SUCCESS)
return res;
+ struct tee_fs_rpc_operation op = {
+ .id = id, .num_params = 3, .params = {
+ [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_RENAME,
+ overwrite, 0),
+ [1] = THREAD_PARAM_MEMREF(IN, mobj, 0, TEE_FS_NAME_MAX),
+ [2] = THREAD_PARAM_MEMREF(IN, mobj, TEE_FS_NAME_MAX,
+ TEE_FS_NAME_MAX),
+ }
+ };
+
return operation_commit(&op);
}
@@ -325,7 +307,6 @@ TEE_Result tee_fs_rpc_opendir(uint32_t id, const TEE_UUID *uuid,
struct tee_fs_dir **d)
{
TEE_Result res;
- struct tee_fs_rpc_operation op = { .id = id, .num_params = 3 };
struct mobj *mobj;
void *va;
struct tee_fs_dir *dir = calloc(1, sizeof(*dir));
@@ -339,17 +320,18 @@ TEE_Result tee_fs_rpc_opendir(uint32_t id, const TEE_UUID *uuid,
goto err_exit;
}
- op.params[0].attr = THREAD_PARAM_ATTR_VALUE_IN;
- op.params[0].u.value.a = OPTEE_MRF_OPENDIR;
-
- init_memparam(op.params + 1, mobj, 0, TEE_FS_NAME_MAX,
- THREAD_PARAM_ATTR_MEMREF_IN);
res = tee_svc_storage_create_dirname(va, TEE_FS_NAME_MAX, uuid);
if (res != TEE_SUCCESS)
goto err_exit;
- op.params[2].attr = THREAD_PARAM_ATTR_VALUE_OUT;
+ struct tee_fs_rpc_operation op = {
+ .id = id, .num_params = 3, .params = {
+ [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_OPENDIR, 0, 0),
+ [1] = THREAD_PARAM_MEMREF(IN, mobj, 0, TEE_FS_NAME_MAX),
+ [2] = THREAD_PARAM_VALUE(OUT, 0, 0, 0),
+ }
+ };
res = operation_commit(&op);
@@ -368,11 +350,12 @@ err_exit:
TEE_Result tee_fs_rpc_closedir(uint32_t id, struct tee_fs_dir *d)
{
- struct tee_fs_rpc_operation op = { .id = id, .num_params = 1 };
-
- op.params[0].attr = THREAD_PARAM_ATTR_VALUE_IN;
- op.params[0].u.value.a = OPTEE_MRF_CLOSEDIR;
- op.params[0].u.value.b = d->nw_dir;
+ struct tee_fs_rpc_operation op = {
+ .id = id, .num_params = 1, .params = {
+ [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_CLOSEDIR,
+ d->nw_dir, 0),
+ }
+ };
free(d);
return operation_commit(&op);
@@ -382,7 +365,6 @@ TEE_Result tee_fs_rpc_readdir(uint32_t id, struct tee_fs_dir *d,
struct tee_fs_dirent **ent)
{
TEE_Result res;
- struct tee_fs_rpc_operation op = { .id = id, .num_params = 2 };
struct mobj *mobj;
void *va;
const size_t max_name_len = TEE_FS_NAME_MAX + 1;
@@ -394,12 +376,13 @@ TEE_Result tee_fs_rpc_readdir(uint32_t id, struct tee_fs_dir *d,
if (!va)
return TEE_ERROR_OUT_OF_MEMORY;
- op.params[0].attr = THREAD_PARAM_ATTR_VALUE_IN;
- op.params[0].u.value.a = OPTEE_MRF_READDIR;
- op.params[0].u.value.b = d->nw_dir;
-
- init_memparam(op.params + 1, mobj, 0, max_name_len,
- THREAD_PARAM_ATTR_MEMREF_OUT);
+ struct tee_fs_rpc_operation op = {
+ .id = id, .num_params = 2, .params = {
+ [0] = THREAD_PARAM_VALUE(IN, OPTEE_MRF_READDIR,
+ d->nw_dir, 0),
+ [1] = THREAD_PARAM_MEMREF(IN, mobj, 0, max_name_len),
+ }
+ };
res = operation_commit(&op);
if (res != TEE_SUCCESS)