Skip to content

Commit

Permalink
OP-TEE: keep compitable with new version driver
Browse files Browse the repository at this point in the history
1.Rename some functions to fix multiple definition compile error.
2.Build optee_linuxdriver when TEE_SUPPORT is enabled.
3.Rename "optee" obj name to "optee_v1" to fix module name conflict error:

[    0.211629] sysfs: cannot create duplicate filename '/module/optee/version'
[    0.211670] ------------[ cut here ]------------
[    0.211684] WARNING: at fs/sysfs/dir.c:31
[    0.211697] Modules linked in:
[    0.211713]
[    0.211726] CPU: 4 PID: 1 Comm: swapper/0 Not tainted 4.4.93 #42
[    0.211738] Hardware name: Rockchip RK3399 Excavator Board edp (Android) (DT)
[    0.211752] task: ffffffc0f2160000 task.stack: ffffffc0f2168000
[    0.211772] PC is at sysfs_warn_dup+0x60/0x7c
[    0.211785] LR is at sysfs_warn_dup+0x60/0x7c

Change-Id: I9cc98307a32d9b186f7aac86027da231b486c487
Signed-off-by: Zhang Zhijie <[email protected]>
  • Loading branch information
ElonZhang0328 authored and rkhuangtao committed Nov 30, 2017
1 parent 60b3b75 commit 0aea51c
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions security/optee_linuxdriver/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
obj-y += core/
obj-y += armtz/
obj-$(CONFIG_TEE_SUPPORT) += core/
obj-$(CONFIG_TEE_SUPPORT) += armtz/
2 changes: 1 addition & 1 deletion security/optee_linuxdriver/armtz/tee_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ unsigned long tee_shm_pool_alloc(struct device *dev,
* the memory region managed by the pool.
*
*/
int tee_shm_pool_free(struct device *dev, struct shm_pool *pool,
int rk_tee_shm_pool_free(struct device *dev, struct shm_pool *pool,
unsigned long paddr, size_t *size)
{
struct mem_chunk *chunk;
Expand Down
2 changes: 1 addition & 1 deletion security/optee_linuxdriver/armtz/tee_mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ unsigned long tee_shm_pool_alloc(struct device *dev,
struct shm_pool *pool,
size_t size, size_t alignment);

int tee_shm_pool_free(struct device *dev, struct shm_pool *pool,
int rk_tee_shm_pool_free(struct device *dev, struct shm_pool *pool,
unsigned long paddr, size_t *size);

bool tee_shm_pool_incref(struct device *dev, struct shm_pool *pool,
Expand Down
8 changes: 4 additions & 4 deletions security/optee_linuxdriver/armtz/tee_tz_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ static u32 handle_rpc(struct tee_tz *ptee, struct smc_param *param)
param->a2 = 0;
break;
case TEESMC_RPC_FUNC_FREE_ARG:
tee_shm_pool_free(DEV, ptee->shm_pool, param->a1, 0);
rk_tee_shm_pool_free(DEV, ptee->shm_pool, param->a1, 0);
break;
case TEESMC_RPC_FUNC_FREE_PAYLOAD:
/* Can't support payload shared memory with this interface */
Expand Down Expand Up @@ -536,7 +536,7 @@ static void free_tee_arg(struct tee_tz *ptee, unsigned long p)
BUG_ON(!CAPABLE(ptee->tee));

if (p)
tee_shm_pool_free(DEV, ptee->shm_pool, p, 0);
rk_tee_shm_pool_free(DEV, ptee->shm_pool, p, 0);

dev_dbg(DEV, "<\n");
}
Expand Down Expand Up @@ -916,7 +916,7 @@ static struct tee_shm *tz_alloc(struct tee *tee, size_t size, uint32_t flags)
if (!shm->kaddr) {
dev_err(tee->dev, "%s: p2v(%pad)=0\n", __func__,
&shm->paddr);
tee_shm_pool_free(tee->dev, ptee->shm_pool, shm->paddr, NULL);
rk_tee_shm_pool_free(tee->dev, ptee->shm_pool, shm->paddr, NULL);
devm_kfree(tee->dev, shm);
return ERR_PTR(-EFAULT);
}
Expand Down Expand Up @@ -945,7 +945,7 @@ static void tz_free(struct tee_shm *shm)

dev_dbg(tee->dev, "%s: shm=%p\n", __func__, shm);

ret = tee_shm_pool_free(tee->dev, ptee->shm_pool, shm->paddr, &size);
ret = rk_tee_shm_pool_free(tee->dev, ptee->shm_pool, shm->paddr, &size);
if (!ret) {
devm_kfree(tee->dev, shm);
shm = NULL;
Expand Down
4 changes: 2 additions & 2 deletions security/optee_linuxdriver/core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ ccflags-y+=-DCFG_TEE_DRV_DEBUGFS=${CFG_TEE_DRV_DEBUGFS}
ccflags-y+=-DCFG_TEE_CORE_LOG_LEVEL=${CFG_TEE_CORE_LOG_LEVEL}
ccflags-y+=-DCFG_TEE_TA_LOG_LEVEL=${CFG_TEE_TA_LOG_LEVEL}

obj-y += optee.o
obj-y += optee_v1.o

optee-objs:= \
optee_v1-objs:= \
tee_core.o \
tee_context.o \
tee_session.o \
Expand Down
4 changes: 2 additions & 2 deletions security/optee_linuxdriver/core/tee_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ struct tee_shm *tee_context_alloc_shm_tmp(struct tee_context *ctx,

type &= (TEEC_MEM_INPUT | TEEC_MEM_OUTPUT);

shm = tee_shm_alloc(ctx->tee, size,
shm = rk_tee_shm_alloc(ctx->tee, size,
TEE_SHM_MAPPED | TEE_SHM_TEMP | type);
if (IS_ERR_OR_NULL(shm)) {
dev_err(_DEV(ctx->tee), "%s: buffer allocation failed (%ld)\n",
Expand All @@ -283,7 +283,7 @@ struct tee_shm *tee_context_alloc_shm_tmp(struct tee_context *ctx,
dev_err(_DEV(ctx->tee),
"%s: tee_context_copy_from_client failed\n",
__func__);
tee_shm_free(shm);
rk_tee_shm_free(shm);
shm = NULL;
}
}
Expand Down
6 changes: 3 additions & 3 deletions security/optee_linuxdriver/core/tee_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ static void _release_tee_cmd(struct tee_session *sess, struct tee_cmd *cmd)

dev_dbg(_DEV_TEE, "%s: > free the temporary objects...\n", __func__);

tee_shm_free(cmd->uuid);
rk_tee_shm_free(cmd->uuid);

if (cmd->param.type_original == TEEC_PARAM_TYPES(TEEC_NONE,
TEEC_NONE, TEEC_NONE, TEEC_NONE))
Expand Down Expand Up @@ -844,9 +844,9 @@ static void _release_tee_cmd(struct tee_session *sess, struct tee_cmd *cmd)
shm = cmd->param.params[idx].shm;

if (is_mapped_temp(shm->flags))
tee_shm_free(shm);
rk_tee_shm_free(shm);
else
tee_shm_put(ctx, shm);
rk_tee_shm_put(ctx, shm);
break;
default:
BUG_ON(1);
Expand Down
16 changes: 8 additions & 8 deletions security/optee_linuxdriver/core/tee_shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct tee_shm *tee_shm_alloc_from_rpc(struct tee *tee, size_t size)
INMSG();

mutex_lock(&tee->lock);
shm = tee_shm_alloc(tee, size, TEE_SHM_TEMP | TEE_SHM_FROM_RPC);
shm = rk_tee_shm_alloc(tee, size, TEE_SHM_TEMP | TEE_SHM_FROM_RPC);
if (IS_ERR_OR_NULL(shm)) {
dev_err(_DEV(tee), "%s: buffer allocation failed (%ld)\n",
__func__, PTR_ERR(shm));
Expand Down Expand Up @@ -75,11 +75,11 @@ void tee_shm_free_from_rpc(struct tee_shm *shm)
list_del(&shm->entry);
}

tee_shm_free(shm);
rk_tee_shm_free(shm);
mutex_unlock(&tee->lock);
}

struct tee_shm *tee_shm_alloc(struct tee *tee, size_t size, uint32_t flags)
struct tee_shm *rk_tee_shm_alloc(struct tee *tee, size_t size, uint32_t flags)
{
struct tee_shm *shm;
unsigned long pfn;
Expand Down Expand Up @@ -128,7 +128,7 @@ struct tee_shm *tee_shm_alloc(struct tee *tee, size_t size, uint32_t flags)
return shm;
}

void tee_shm_free(struct tee_shm *shm)
void rk_tee_shm_free(struct tee_shm *shm)
{
struct tee *tee;

Expand Down Expand Up @@ -402,7 +402,7 @@ int tee_shm_alloc_io(struct tee_context *ctx, struct tee_shm_io *shm_io)
shm_io->fd_shm = 0;

mutex_lock(&tee->lock);
shm = tee_shm_alloc(tee, shm_io->size, shm_io->flags);
shm = rk_tee_shm_alloc(tee, shm_io->size, shm_io->flags);
if (IS_ERR_OR_NULL(shm)) {
dev_err(_DEV(tee), "%s: buffer allocation failed (%ld)\n",
__func__, PTR_ERR(shm));
Expand All @@ -413,7 +413,7 @@ int tee_shm_alloc_io(struct tee_context *ctx, struct tee_shm_io *shm_io)
if (ctx->usr_client) {
ret = export_buf(tee, shm, &shm_io->fd_shm);
if (ret) {
tee_shm_free(shm);
rk_tee_shm_free(shm);
ret = -ENOMEM;
goto out;
}
Expand Down Expand Up @@ -445,7 +445,7 @@ void tee_shm_free_io(struct tee_shm *shm)
tee_dec_stats(&tee->stats[TEE_STATS_SHM_IDX]);
list_del(&shm->entry);

tee_shm_free(shm);
rk_tee_shm_free(shm);
tee_put(ctx->tee);
tee_context_put(ctx);
if (dev)
Expand Down Expand Up @@ -787,7 +787,7 @@ struct tee_shm *tee_shm_get(struct tee_context *ctx, TEEC_SharedMemory *c_shm,
return ERR_PTR(ret);
}

void tee_shm_put(struct tee_context *ctx, struct tee_shm *shm)
void rk_tee_shm_put(struct tee_context *ctx, struct tee_shm *shm)
{
struct tee *tee = ctx->tee;

Expand Down
6 changes: 3 additions & 3 deletions security/optee_linuxdriver/core/tee_shm.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ void tee_shm_free_io(struct tee_shm *shm);

int tee_shm_fd_for_rpc(struct tee_context *ctx, struct tee_shm_io *shm_io);

struct tee_shm *tee_shm_alloc(struct tee *tee, size_t size, uint32_t flags);
void tee_shm_free(struct tee_shm *shm);
struct tee_shm *rk_tee_shm_alloc(struct tee *tee, size_t size, uint32_t flags);
void rk_tee_shm_free(struct tee_shm *shm);

struct tee_shm *tee_shm_get(struct tee_context *ctx, TEEC_SharedMemory *c_shm,
size_t size, int offset);
void tee_shm_put(struct tee_context *ctx, struct tee_shm *shm);
void rk_tee_shm_put(struct tee_context *ctx, struct tee_shm *shm);

#endif /* __TEE_SHM_H__ */

0 comments on commit 0aea51c

Please sign in to comment.