diff options
author | Joakim Bech <joakim.xx.bech@stericsson.com> | 2011-11-25 14:56:06 +0100 |
---|---|---|
committer | Philippe Langlais <philippe.langlais@stericsson.com> | 2012-05-22 11:04:39 +0200 |
commit | 76a9eb20c263866946d74df422a879fb21af54f3 (patch) | |
tree | 5ee6da7de64276bf69319da4864ae06fa014fe9f /drivers/tee/tee_driver.c | |
parent | 356d0c567bcdd463fb19971841a46fb17b776f61 (diff) |
ux500: TEE: Moved conversion of virt_to_phys
If memory allocation failed when trying to copy memrefs from user space
to kernel space we jumped to error handling code which tried to free the
memrefs that had been allocated previously. The problem was that after
each allocation we converted the allocated buffers to physical
addresses, hence if any of the allocations except the first one failed
we ended up trying to free a physical address. In this patch we have
moved the translation from virtual to physical addresses to be done
after all allocations have succeeded.
ST-Ericsson ID: 374810, 374493, 374920
ST-Ericsson FOSS-OUT ID: NA
ST-Ericsson Linux next: NA
Change-Id: I3a109a9ebb46f74a2089916fa300bf6f4347501b
Signed-off-by: Joakim Bech <joakim.xx.bech@stericsson.com>
Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/39876
Reviewed-by: QATOOLS
Reviewed-by: QABUILD
Reviewed-by: QATEST
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
Diffstat (limited to 'drivers/tee/tee_driver.c')
-rw-r--r-- | drivers/tee/tee_driver.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/tee/tee_driver.c b/drivers/tee/tee_driver.c index 8bafcf1e755..feabe3615c1 100644 --- a/drivers/tee/tee_driver.c +++ b/drivers/tee/tee_driver.c @@ -110,6 +110,18 @@ static inline void memrefs_phys_to_virt(struct tee_session *ts) } } +static inline void memrefs_virt_to_phys(struct tee_session *ts) +{ + int i; + + for (i = 0; i < 4; ++i) { + if (ts->op->flags & (1 << i)) { + ts->op->shm[i].buffer = + (void *)virt_to_phys(ts->op->shm[i].buffer); + } + } +} + static int copy_memref_to_user(struct tee_operation *op, struct tee_operation *ubuf_op, int memref) @@ -170,9 +182,6 @@ static int copy_memref_to_kernel(struct tee_operation *op, op->shm[memref].size = kbuf_op->shm[memref].size; op->shm[memref].flags = kbuf_op->shm[memref].flags; - /* Secure world expects physical addresses. */ - op->shm[memref].buffer = (void *)virt_to_phys(op->shm[memref].buffer); - return 0; } @@ -238,7 +247,9 @@ static int invoke_command(struct tee_session *ts, } } - /* To call secure world */ + /* Secure world expects physical addresses. */ + memrefs_virt_to_phys(ts); + if (call_sec_world(ts, TEED_INVOKE)) { ret = -EINVAL; goto err; |