提交 45848f1d 编写于 作者: A Arnd Bergmann

Merge tag 'tee-drv-for-4.14' of...

Merge tag 'tee-drv-for-4.14' of http://git.linaro.org/people/jens.wiklander/linux-tee into next/drivers

Pull "Small fixes and enhancements for the TEE subsystem" from Jens Wiklander:

* tag 'tee-drv-for-4.14' of http://git.linaro.org/people/jens.wiklander/linux-tee:
  tee: optee: sync with new naming of interrupts
  tee: indicate privileged dev in gen_caps
  tee: optee: interruptible RPC sleep
  tee: optee: add const to tee_driver_ops and tee_desc structures
  tee: tee_shm: Constify dma_buf_ops structures.
  tee: add forward declaration for struct device
  tee: optee: fix uninitialized symbol 'parg'
...@@ -224,13 +224,14 @@ static void optee_release(struct tee_context *ctx) ...@@ -224,13 +224,14 @@ static void optee_release(struct tee_context *ctx)
if (!IS_ERR(shm)) { if (!IS_ERR(shm)) {
arg = tee_shm_get_va(shm, 0); arg = tee_shm_get_va(shm, 0);
/* /*
* If va2pa fails for some reason, we can't call * If va2pa fails for some reason, we can't call into
* optee_close_session(), only free the memory. Secure OS * secure world, only free the memory. Secure OS will leak
* will leak sessions and finally refuse more sessions, but * sessions and finally refuse more sessions, but we will
* we will at least let normal world reclaim its memory. * at least let normal world reclaim its memory.
*/ */
if (!IS_ERR(arg)) if (!IS_ERR(arg))
tee_shm_va2pa(shm, arg, &parg); if (tee_shm_va2pa(shm, arg, &parg))
arg = NULL; /* prevent usage of parg below */
} }
list_for_each_entry_safe(sess, sess_tmp, &ctxdata->sess_list, list_for_each_entry_safe(sess, sess_tmp, &ctxdata->sess_list,
...@@ -258,7 +259,7 @@ static void optee_release(struct tee_context *ctx) ...@@ -258,7 +259,7 @@ static void optee_release(struct tee_context *ctx)
} }
} }
static struct tee_driver_ops optee_ops = { static const struct tee_driver_ops optee_ops = {
.get_version = optee_get_version, .get_version = optee_get_version,
.open = optee_open, .open = optee_open,
.release = optee_release, .release = optee_release,
...@@ -268,13 +269,13 @@ static struct tee_driver_ops optee_ops = { ...@@ -268,13 +269,13 @@ static struct tee_driver_ops optee_ops = {
.cancel_req = optee_cancel_req, .cancel_req = optee_cancel_req,
}; };
static struct tee_desc optee_desc = { static const struct tee_desc optee_desc = {
.name = DRIVER_NAME "-clnt", .name = DRIVER_NAME "-clnt",
.ops = &optee_ops, .ops = &optee_ops,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
static struct tee_driver_ops optee_supp_ops = { static const struct tee_driver_ops optee_supp_ops = {
.get_version = optee_get_version, .get_version = optee_get_version,
.open = optee_open, .open = optee_open,
.release = optee_release, .release = optee_release,
...@@ -282,7 +283,7 @@ static struct tee_driver_ops optee_supp_ops = { ...@@ -282,7 +283,7 @@ static struct tee_driver_ops optee_supp_ops = {
.supp_send = optee_supp_send, .supp_send = optee_supp_send,
}; };
static struct tee_desc optee_supp_desc = { static const struct tee_desc optee_supp_desc = {
.name = DRIVER_NAME "-supp", .name = DRIVER_NAME "-supp",
.ops = &optee_supp_ops, .ops = &optee_supp_ops,
.owner = THIS_MODULE, .owner = THIS_MODULE,
......
...@@ -298,7 +298,7 @@ struct optee_smc_disable_shm_cache_result { ...@@ -298,7 +298,7 @@ struct optee_smc_disable_shm_cache_result {
OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_ENABLE_SHM_CACHE) OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_ENABLE_SHM_CACHE)
/* /*
* Resume from RPC (for example after processing an IRQ) * Resume from RPC (for example after processing a foreign interrupt)
* *
* Call register usage: * Call register usage:
* a0 SMC Function ID, OPTEE_SMC_CALL_RETURN_FROM_RPC * a0 SMC Function ID, OPTEE_SMC_CALL_RETURN_FROM_RPC
...@@ -383,19 +383,19 @@ struct optee_smc_disable_shm_cache_result { ...@@ -383,19 +383,19 @@ struct optee_smc_disable_shm_cache_result {
OPTEE_SMC_RPC_VAL(OPTEE_SMC_RPC_FUNC_FREE) OPTEE_SMC_RPC_VAL(OPTEE_SMC_RPC_FUNC_FREE)
/* /*
* Deliver an IRQ in normal world. * Deliver foreign interrupt to normal world.
* *
* "Call" register usage: * "Call" register usage:
* a0 OPTEE_SMC_RETURN_RPC_IRQ * a0 OPTEE_SMC_RETURN_RPC_FOREIGN_INTR
* a1-7 Resume information, must be preserved * a1-7 Resume information, must be preserved
* *
* "Return" register usage: * "Return" register usage:
* a0 SMC Function ID, OPTEE_SMC_CALL_RETURN_FROM_RPC. * a0 SMC Function ID, OPTEE_SMC_CALL_RETURN_FROM_RPC.
* a1-7 Preserved * a1-7 Preserved
*/ */
#define OPTEE_SMC_RPC_FUNC_IRQ 4 #define OPTEE_SMC_RPC_FUNC_FOREIGN_INTR 4
#define OPTEE_SMC_RETURN_RPC_IRQ \ #define OPTEE_SMC_RETURN_RPC_FOREIGN_INTR \
OPTEE_SMC_RPC_VAL(OPTEE_SMC_RPC_FUNC_IRQ) OPTEE_SMC_RPC_VAL(OPTEE_SMC_RPC_FUNC_FOREIGN_INTR)
/* /*
* Do an RPC request. The supplied struct optee_msg_arg tells which * Do an RPC request. The supplied struct optee_msg_arg tells which
......
...@@ -140,11 +140,8 @@ static void handle_rpc_func_cmd_wait(struct optee_msg_arg *arg) ...@@ -140,11 +140,8 @@ static void handle_rpc_func_cmd_wait(struct optee_msg_arg *arg)
msec_to_wait = arg->params[0].u.value.a; msec_to_wait = arg->params[0].u.value.a;
/* set task's state to interruptible sleep */ /* Go to interruptible sleep */
set_current_state(TASK_INTERRUPTIBLE); msleep_interruptible(msec_to_wait);
/* take a nap */
msleep(msec_to_wait);
arg->ret = TEEC_SUCCESS; arg->ret = TEEC_SUCCESS;
return; return;
...@@ -374,11 +371,11 @@ void optee_handle_rpc(struct tee_context *ctx, struct optee_rpc_param *param) ...@@ -374,11 +371,11 @@ void optee_handle_rpc(struct tee_context *ctx, struct optee_rpc_param *param)
shm = reg_pair_to_ptr(param->a1, param->a2); shm = reg_pair_to_ptr(param->a1, param->a2);
tee_shm_free(shm); tee_shm_free(shm);
break; break;
case OPTEE_SMC_RPC_FUNC_IRQ: case OPTEE_SMC_RPC_FUNC_FOREIGN_INTR:
/* /*
* An IRQ was raised while secure world was executing, * A foreign interrupt was raised while secure world was
* since all IRQs are handled in Linux a dummy RPC is * executing, since they are handled in Linux a dummy RPC is
* performed to let Linux take the IRQ through the normal * performed to let Linux take the interrupt through the normal
* vector. * vector.
*/ */
break; break;
......
...@@ -90,8 +90,13 @@ static int tee_ioctl_version(struct tee_context *ctx, ...@@ -90,8 +90,13 @@ static int tee_ioctl_version(struct tee_context *ctx,
struct tee_ioctl_version_data vers; struct tee_ioctl_version_data vers;
ctx->teedev->desc->ops->get_version(ctx->teedev, &vers); ctx->teedev->desc->ops->get_version(ctx->teedev, &vers);
if (ctx->teedev->desc->flags & TEE_DESC_PRIVILEGED)
vers.gen_caps |= TEE_GEN_CAP_PRIVILEGED;
if (copy_to_user(uvers, &vers, sizeof(vers))) if (copy_to_user(uvers, &vers, sizeof(vers)))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
......
...@@ -80,7 +80,7 @@ static int tee_shm_op_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma) ...@@ -80,7 +80,7 @@ static int tee_shm_op_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
size, vma->vm_page_prot); size, vma->vm_page_prot);
} }
static struct dma_buf_ops tee_shm_dma_buf_ops = { static const struct dma_buf_ops tee_shm_dma_buf_ops = {
.map_dma_buf = tee_shm_op_map_dma_buf, .map_dma_buf = tee_shm_op_map_dma_buf,
.unmap_dma_buf = tee_shm_op_unmap_dma_buf, .unmap_dma_buf = tee_shm_op_unmap_dma_buf,
.release = tee_shm_op_release, .release = tee_shm_op_release,
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#define TEE_SHM_MAPPED 0x1 /* Memory mapped by the kernel */ #define TEE_SHM_MAPPED 0x1 /* Memory mapped by the kernel */
#define TEE_SHM_DMA_BUF 0x2 /* Memory with dma-buf handle */ #define TEE_SHM_DMA_BUF 0x2 /* Memory with dma-buf handle */
struct device;
struct tee_device; struct tee_device;
struct tee_shm; struct tee_shm;
struct tee_shm_pool; struct tee_shm_pool;
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#define TEE_MAX_ARG_SIZE 1024 #define TEE_MAX_ARG_SIZE 1024
#define TEE_GEN_CAP_GP (1 << 0)/* GlobalPlatform compliant TEE */ #define TEE_GEN_CAP_GP (1 << 0)/* GlobalPlatform compliant TEE */
#define TEE_GEN_CAP_PRIVILEGED (1 << 1)/* Privileged device (for supplicant) */
/* /*
* TEE Implementation ID * TEE Implementation ID
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册