summaryrefslogtreecommitdiff
path: root/drivers/tee/amdtee/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tee/amdtee/core.c')
-rw-r--r--drivers/tee/amdtee/core.c52
1 files changed, 4 insertions, 48 deletions
diff --git a/drivers/tee/amdtee/core.c b/drivers/tee/amdtee/core.c
index a1347d04b3ac..0e56f4cf2697 100644
--- a/drivers/tee/amdtee/core.c
+++ b/drivers/tee/amdtee/core.c
@@ -43,8 +43,6 @@ static int amdtee_open(struct tee_context *ctx)
return -ENOMEM;
INIT_LIST_HEAD(&ctxdata->sess_list);
- INIT_LIST_HEAD(&ctxdata->shm_list);
- mutex_init(&ctxdata->shm_mutex);
ctx->data = ctxdata;
return 0;
@@ -87,7 +85,6 @@ static void amdtee_release(struct tee_context *ctx)
list_del(&sess->list_node);
release_session(sess);
}
- mutex_destroy(&ctxdata->shm_mutex);
kfree(ctxdata);
ctx->data = NULL;
@@ -152,23 +149,6 @@ static struct amdtee_session *find_session(struct amdtee_context_data *ctxdata,
return NULL;
}
-u32 get_buffer_id(struct tee_shm *shm)
-{
- struct amdtee_context_data *ctxdata = shm->ctx->data;
- struct amdtee_shm_data *shmdata;
- u32 buf_id = 0;
-
- mutex_lock(&ctxdata->shm_mutex);
- list_for_each_entry(shmdata, &ctxdata->shm_list, shm_node)
- if (shmdata->kaddr == shm->kaddr) {
- buf_id = shmdata->buf_id;
- break;
- }
- mutex_unlock(&ctxdata->shm_mutex);
-
- return buf_id;
-}
-
static DEFINE_MUTEX(drv_mutex);
static int copy_ta_binary(struct tee_context *ctx, void *ptr, void **ta,
size_t *ta_size)
@@ -342,8 +322,6 @@ int amdtee_close_session(struct tee_context *ctx, u32 session)
int amdtee_map_shmem(struct tee_shm *shm)
{
- struct amdtee_context_data *ctxdata;
- struct amdtee_shm_data *shmnode;
struct shmem_desc shmem;
int rc, count;
u32 buf_id;
@@ -351,10 +329,6 @@ int amdtee_map_shmem(struct tee_shm *shm)
if (!shm)
return -EINVAL;
- shmnode = kmalloc_obj(*shmnode);
- if (!shmnode)
- return -ENOMEM;
-
count = 1;
shmem.kaddr = shm->kaddr;
shmem.size = shm->size;
@@ -366,44 +340,26 @@ int amdtee_map_shmem(struct tee_shm *shm)
rc = handle_map_shmem(count, &shmem, &buf_id);
if (rc) {
pr_err("map_shmem failed: ret = %d\n", rc);
- kfree(shmnode);
return rc;
}
- shmnode->kaddr = shm->kaddr;
- shmnode->buf_id = buf_id;
- ctxdata = shm->ctx->data;
- mutex_lock(&ctxdata->shm_mutex);
- list_add(&shmnode->shm_node, &ctxdata->shm_list);
- mutex_unlock(&ctxdata->shm_mutex);
+ shm->sec_world_id = buf_id;
- pr_debug("buf_id :[%x] kaddr[%p]\n", shmnode->buf_id, shmnode->kaddr);
+ pr_debug("buf_id :[%x] kaddr[%p]\n", buf_id, shm->kaddr);
return 0;
}
void amdtee_unmap_shmem(struct tee_shm *shm)
{
- struct amdtee_context_data *ctxdata;
- struct amdtee_shm_data *shmnode;
u32 buf_id;
if (!shm)
return;
- buf_id = get_buffer_id(shm);
- /* Unmap the shared memory from TEE */
+ buf_id = (u32)shm->sec_world_id;
handle_unmap_shmem(buf_id);
-
- ctxdata = shm->ctx->data;
- mutex_lock(&ctxdata->shm_mutex);
- list_for_each_entry(shmnode, &ctxdata->shm_list, shm_node)
- if (buf_id == shmnode->buf_id) {
- list_del(&shmnode->shm_node);
- kfree(shmnode);
- break;
- }
- mutex_unlock(&ctxdata->shm_mutex);
+ shm->sec_world_id = 0;
}
int amdtee_invoke_func(struct tee_context *ctx,