.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2015, Linaro Limited |
---|
3 | | - * |
---|
4 | | - * This software is licensed under the terms of the GNU General Public |
---|
5 | | - * License version 2, as published by the Free Software Foundation, and |
---|
6 | | - * may be copied, distributed, and modified under those terms. |
---|
7 | | - * |
---|
8 | | - * This program is distributed in the hope that it will be useful, |
---|
9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | | - * GNU General Public License for more details. |
---|
12 | | - * |
---|
13 | 4 | */ |
---|
14 | 5 | #include <linux/arm-smccc.h> |
---|
15 | 6 | #include <linux/device.h> |
---|
16 | 7 | #include <linux/err.h> |
---|
17 | 8 | #include <linux/errno.h> |
---|
18 | 9 | #include <linux/mm.h> |
---|
| 10 | +#include <linux/sched.h> |
---|
19 | 11 | #include <linux/slab.h> |
---|
20 | 12 | #include <linux/tee_drv.h> |
---|
21 | 13 | #include <linux/types.h> |
---|
.. | .. |
---|
157 | 149 | */ |
---|
158 | 150 | optee_cq_wait_for_completion(&optee->call_queue, &w); |
---|
159 | 151 | } else if (OPTEE_SMC_RETURN_IS_RPC(res.a0)) { |
---|
| 152 | + if (need_resched()) |
---|
| 153 | + cond_resched(); |
---|
160 | 154 | param.a0 = res.a0; |
---|
161 | 155 | param.a1 = res.a1; |
---|
162 | 156 | param.a2 = res.a2; |
---|
.. | .. |
---|
187 | 181 | struct optee_msg_arg *ma; |
---|
188 | 182 | |
---|
189 | 183 | shm = tee_shm_alloc(ctx, OPTEE_MSG_GET_ARG_SIZE(num_params), |
---|
190 | | - TEE_SHM_MAPPED); |
---|
| 184 | + TEE_SHM_MAPPED | TEE_SHM_PRIV); |
---|
191 | 185 | if (IS_ERR(shm)) |
---|
192 | 186 | return shm; |
---|
193 | 187 | |
---|
.. | .. |
---|
223 | 217 | struct optee_msg_arg *msg_arg; |
---|
224 | 218 | phys_addr_t msg_parg; |
---|
225 | 219 | struct optee_session *sess = NULL; |
---|
| 220 | + uuid_t client_uuid; |
---|
226 | 221 | |
---|
227 | 222 | /* +2 for the meta parameters added below */ |
---|
228 | 223 | shm = get_msg_arg(ctx, arg->num_params + 2, &msg_arg, &msg_parg); |
---|
.. | .. |
---|
241 | 236 | msg_arg->params[1].attr = OPTEE_MSG_ATTR_TYPE_VALUE_INPUT | |
---|
242 | 237 | OPTEE_MSG_ATTR_META; |
---|
243 | 238 | memcpy(&msg_arg->params[0].u.value, arg->uuid, sizeof(arg->uuid)); |
---|
244 | | - memcpy(&msg_arg->params[1].u.value, arg->uuid, sizeof(arg->clnt_uuid)); |
---|
245 | 239 | msg_arg->params[1].u.value.c = arg->clnt_login; |
---|
| 240 | + |
---|
| 241 | + rc = tee_session_calc_client_uuid(&client_uuid, arg->clnt_login, |
---|
| 242 | + arg->clnt_uuid); |
---|
| 243 | + if (rc) |
---|
| 244 | + goto out; |
---|
| 245 | + export_uuid(msg_arg->params[1].u.octets, &client_uuid); |
---|
246 | 246 | |
---|
247 | 247 | rc = optee_to_msg_param(msg_arg->params + 2, arg->num_params, param); |
---|
248 | 248 | if (rc) |
---|
.. | .. |
---|
593 | 593 | struct mm_struct *mm = current->mm; |
---|
594 | 594 | int rc; |
---|
595 | 595 | |
---|
596 | | - down_read(&mm->mmap_sem); |
---|
| 596 | + /* |
---|
| 597 | + * Allow kernel address to register with OP-TEE as kernel |
---|
| 598 | + * pages are configured as normal memory only. |
---|
| 599 | + */ |
---|
| 600 | + if (virt_addr_valid(start)) |
---|
| 601 | + return 0; |
---|
| 602 | + |
---|
| 603 | + mmap_read_lock(mm); |
---|
597 | 604 | rc = __check_mem_type(find_vma(mm, start), |
---|
598 | 605 | start + num_pages * PAGE_SIZE); |
---|
599 | | - up_read(&mm->mmap_sem); |
---|
| 606 | + mmap_read_unlock(mm); |
---|
600 | 607 | |
---|
601 | 608 | return rc; |
---|
602 | 609 | } |
---|