• Home
  • Raw
  • Download

Lines Matching +full:op +full:- +full:tee

1 // SPDX-License-Identifier: GPL-2.0-only
5 #include <linux/arm-smccc.h>
34 mutex_lock(&cq->mutex); in optee_cq_wait_init()
42 init_completion(&w->c); in optee_cq_wait_init()
43 list_add_tail(&w->list_node, &cq->waiters); in optee_cq_wait_init()
45 mutex_unlock(&cq->mutex); in optee_cq_wait_init()
51 wait_for_completion(&w->c); in optee_cq_wait_for_completion()
53 mutex_lock(&cq->mutex); in optee_cq_wait_for_completion()
56 list_del(&w->list_node); in optee_cq_wait_for_completion()
57 reinit_completion(&w->c); in optee_cq_wait_for_completion()
58 list_add_tail(&w->list_node, &cq->waiters); in optee_cq_wait_for_completion()
60 mutex_unlock(&cq->mutex); in optee_cq_wait_for_completion()
67 list_for_each_entry(w, &cq->waiters, list_node) { in optee_cq_complete_one()
68 if (!completion_done(&w->c)) { in optee_cq_complete_one()
69 complete(&w->c); in optee_cq_complete_one()
83 mutex_lock(&cq->mutex); in optee_cq_wait_final()
86 list_del(&w->list_node); in optee_cq_wait_final()
97 if (completion_done(&w->c)) in optee_cq_wait_final()
100 mutex_unlock(&cq->mutex); in optee_cq_wait_final()
109 list_for_each_entry(sess, &ctxdata->sess_list, list_node) in find_session()
110 if (sess->session_id == session_id) in find_session()
117 * optee_do_call_with_arg() - Do an SMC to OP-TEE in secure world
121 * Does and SMC to OP-TEE in secure world and handles eventual resulting
122 * Remote Procedure Calls (RPC) from OP-TEE.
128 struct optee *optee = tee_get_drvdata(ctx->teedev); in optee_do_call_with_arg()
137 optee_cq_wait_init(&optee->call_queue, &w); in optee_do_call_with_arg()
141 optee->invoke_fn(param.a0, param.a1, param.a2, param.a3, in optee_do_call_with_arg()
150 optee_cq_wait_for_completion(&optee->call_queue, &w); in optee_do_call_with_arg()
170 optee_cq_wait_final(&optee->call_queue, &w); in optee_do_call_with_arg()
199 ma->num_params = num_params; in get_msg_arg()
214 struct optee_context_data *ctxdata = ctx->data; in optee_open_session()
223 shm = get_msg_arg(ctx, arg->num_params + 2, &msg_arg, &msg_parg); in optee_open_session()
227 msg_arg->cmd = OPTEE_MSG_CMD_OPEN_SESSION; in optee_open_session()
228 msg_arg->cancel_id = arg->cancel_id; in optee_open_session()
234 msg_arg->params[0].attr = OPTEE_MSG_ATTR_TYPE_VALUE_INPUT | in optee_open_session()
236 msg_arg->params[1].attr = OPTEE_MSG_ATTR_TYPE_VALUE_INPUT | in optee_open_session()
238 memcpy(&msg_arg->params[0].u.value, arg->uuid, sizeof(arg->uuid)); in optee_open_session()
239 msg_arg->params[1].u.value.c = arg->clnt_login; in optee_open_session()
241 rc = tee_session_calc_client_uuid(&client_uuid, arg->clnt_login, in optee_open_session()
242 arg->clnt_uuid); in optee_open_session()
245 export_uuid(msg_arg->params[1].u.octets, &client_uuid); in optee_open_session()
247 rc = optee_to_msg_param(msg_arg->params + 2, arg->num_params, param); in optee_open_session()
253 rc = -ENOMEM; in optee_open_session()
258 msg_arg->ret = TEEC_ERROR_COMMUNICATION; in optee_open_session()
259 msg_arg->ret_origin = TEEC_ORIGIN_COMMS; in optee_open_session()
262 if (msg_arg->ret == TEEC_SUCCESS) { in optee_open_session()
264 sess->session_id = msg_arg->session; in optee_open_session()
265 mutex_lock(&ctxdata->mutex); in optee_open_session()
266 list_add(&sess->list_node, &ctxdata->sess_list); in optee_open_session()
267 mutex_unlock(&ctxdata->mutex); in optee_open_session()
272 if (optee_from_msg_param(param, arg->num_params, msg_arg->params + 2)) { in optee_open_session()
273 arg->ret = TEEC_ERROR_COMMUNICATION; in optee_open_session()
274 arg->ret_origin = TEEC_ORIGIN_COMMS; in optee_open_session()
276 optee_close_session(ctx, msg_arg->session); in optee_open_session()
278 arg->session = msg_arg->session; in optee_open_session()
279 arg->ret = msg_arg->ret; in optee_open_session()
280 arg->ret_origin = msg_arg->ret_origin; in optee_open_session()
290 struct optee_context_data *ctxdata = ctx->data; in optee_close_session()
297 mutex_lock(&ctxdata->mutex); in optee_close_session()
300 list_del(&sess->list_node); in optee_close_session()
301 mutex_unlock(&ctxdata->mutex); in optee_close_session()
303 return -EINVAL; in optee_close_session()
310 msg_arg->cmd = OPTEE_MSG_CMD_CLOSE_SESSION; in optee_close_session()
311 msg_arg->session = session; in optee_close_session()
321 struct optee_context_data *ctxdata = ctx->data; in optee_invoke_func()
329 mutex_lock(&ctxdata->mutex); in optee_invoke_func()
330 sess = find_session(ctxdata, arg->session); in optee_invoke_func()
331 mutex_unlock(&ctxdata->mutex); in optee_invoke_func()
333 return -EINVAL; in optee_invoke_func()
335 shm = get_msg_arg(ctx, arg->num_params, &msg_arg, &msg_parg); in optee_invoke_func()
338 msg_arg->cmd = OPTEE_MSG_CMD_INVOKE_COMMAND; in optee_invoke_func()
339 msg_arg->func = arg->func; in optee_invoke_func()
340 msg_arg->session = arg->session; in optee_invoke_func()
341 msg_arg->cancel_id = arg->cancel_id; in optee_invoke_func()
343 rc = optee_to_msg_param(msg_arg->params, arg->num_params, param); in optee_invoke_func()
348 msg_arg->ret = TEEC_ERROR_COMMUNICATION; in optee_invoke_func()
349 msg_arg->ret_origin = TEEC_ORIGIN_COMMS; in optee_invoke_func()
352 if (optee_from_msg_param(param, arg->num_params, msg_arg->params)) { in optee_invoke_func()
353 msg_arg->ret = TEEC_ERROR_COMMUNICATION; in optee_invoke_func()
354 msg_arg->ret_origin = TEEC_ORIGIN_COMMS; in optee_invoke_func()
357 arg->ret = msg_arg->ret; in optee_invoke_func()
358 arg->ret_origin = msg_arg->ret_origin; in optee_invoke_func()
366 struct optee_context_data *ctxdata = ctx->data; in optee_cancel_req()
373 mutex_lock(&ctxdata->mutex); in optee_cancel_req()
375 mutex_unlock(&ctxdata->mutex); in optee_cancel_req()
377 return -EINVAL; in optee_cancel_req()
383 msg_arg->cmd = OPTEE_MSG_CMD_CANCEL; in optee_cancel_req()
384 msg_arg->session = session; in optee_cancel_req()
385 msg_arg->cancel_id = cancel_id; in optee_cancel_req()
393 * optee_enable_shm_cache() - Enables caching of some shared memory allocation
394 * in OP-TEE
402 optee_cq_wait_init(&optee->call_queue, &w); in optee_enable_shm_cache()
406 optee->invoke_fn(OPTEE_SMC_ENABLE_SHM_CACHE, 0, 0, 0, 0, 0, 0, in optee_enable_shm_cache()
410 optee_cq_wait_for_completion(&optee->call_queue, &w); in optee_enable_shm_cache()
412 optee_cq_wait_final(&optee->call_queue, &w); in optee_enable_shm_cache()
416 * __optee_disable_shm_cache() - Disables caching of some shared memory
417 * allocation in OP-TEE
427 optee_cq_wait_init(&optee->call_queue, &w); in __optee_disable_shm_cache()
434 optee->invoke_fn(OPTEE_SMC_DISABLE_SHM_CACHE, 0, 0, 0, 0, 0, 0, in __optee_disable_shm_cache()
452 optee_cq_wait_for_completion(&optee->call_queue, &w); in __optee_disable_shm_cache()
455 optee_cq_wait_final(&optee->call_queue, &w); in __optee_disable_shm_cache()
459 * optee_disable_shm_cache() - Disables caching of mapped shared memory
460 * allocations in OP-TEE
469 * optee_disable_unmapped_shm_cache() - Disables caching of shared memory
470 * allocations in OP-TEE which are not
480 ((OPTEE_MSG_NONCONTIG_PAGE_SIZE / sizeof(u64)) - 1)
483 * optee_fill_pages_list() - write list of user pages to given shared
486 * @dst: page-aligned buffer where list of pages will be stored
509 * Currently OP-TEE uses 4k page size and it does not looks in optee_fill_pages_list()
522 * because they bear no value data for OP-TEE. in optee_fill_pages_list()
528 pages_data->pages_list[n++] = optee_page; in optee_fill_pages_list()
531 pages_data->next_page_data = in optee_fill_pages_list()
539 if (!--num_pages) in optee_fill_pages_list()
582 while (vma && is_normal_memory(vma->vm_page_prot)) { in __check_mem_type()
583 if (vma->vm_end >= end) in __check_mem_type()
585 vma = vma->vm_next; in __check_mem_type()
588 return -EINVAL; in __check_mem_type()
593 struct mm_struct *mm = current->mm; in check_mem_type()
597 * Allow kernel address to register with OP-TEE as kernel in check_mem_type()
622 return -EINVAL; in optee_shm_register()
630 return -ENOMEM; in optee_shm_register()
641 msg_arg->cmd = OPTEE_MSG_CMD_REGISTER_SHM; in optee_shm_register()
642 msg_arg->params->attr = OPTEE_MSG_ATTR_TYPE_TMEM_OUTPUT | in optee_shm_register()
644 msg_arg->params->u.tmem.shm_ref = (unsigned long)shm; in optee_shm_register()
645 msg_arg->params->u.tmem.size = tee_shm_get_size(shm); in optee_shm_register()
647 * In the least bits of msg_arg->params->u.tmem.buf_ptr we in optee_shm_register()
648 * store buffer offset from 4k page, as described in OP-TEE ABI. in optee_shm_register()
650 msg_arg->params->u.tmem.buf_ptr = virt_to_phys(pages_list) | in optee_shm_register()
651 (tee_shm_get_page_offset(shm) & (OPTEE_MSG_NONCONTIG_PAGE_SIZE - 1)); in optee_shm_register()
654 msg_arg->ret != TEEC_SUCCESS) in optee_shm_register()
655 rc = -EINVAL; in optee_shm_register()
674 msg_arg->cmd = OPTEE_MSG_CMD_UNREGISTER_SHM; in optee_shm_unregister()
676 msg_arg->params[0].attr = OPTEE_MSG_ATTR_TYPE_RMEM_INPUT; in optee_shm_unregister()
677 msg_arg->params[0].u.rmem.shm_ref = (unsigned long)shm; in optee_shm_unregister()
680 msg_arg->ret != TEEC_SUCCESS) in optee_shm_unregister()
681 rc = -EINVAL; in optee_shm_unregister()
691 * We don't want to register supplicant memory in OP-TEE. in optee_shm_register_supp()