History

tee: add tee_shm_register_{user,kernel}_buf()

Adds the two new functions tee_shm_register_user_buf() and tee_shm_register_kernel_buf() which should be used instead of the old tee_shm_register(). This avoids having the caller supplying the flags parameter which exposes a bit more than desired of the internals of the TEE subsystem.

Jens Wiklander committed 4 years ago

Commit 056d3fe1 parent 924e3224 files · +38 −2Browse files

Unified · Split

4 files
  1. drivers/tee/tee_core.c +1 −2
  2. drivers/tee/tee_private.h +2 −0
  3. drivers/tee/tee_shm.c +33 −0
  4. include/linux/tee_drv.h +2 −0
drivers/tee/tee_core.c+1−2
@@ -334,8 +334,7 @@ tee_ioctl_shm_register(struct tee_context *ctx, · 333 unmodified lines
334 if (data.flags)334 if (data.flags)
335 return -EINVAL;335 return -EINVAL;
336 336
337 shm = tee_shm_register(ctx, data.addr, data.length,337 shm = tee_shm_register_user_buf(ctx, data.addr, data.length);
338 TEE_SHM_DMA_BUF | TEE_SHM_USER_MAPPED);
339 if (IS_ERR(shm))338 if (IS_ERR(shm))
340 return PTR_ERR(shm);339 return PTR_ERR(shm);
341 340
drivers/tee/tee_private.h+2−0
@@ -58,5 +58,7 @@ void teedev_ctx_get(struct tee_context *ctx); · 57 unmodified lines
58void teedev_ctx_put(struct tee_context *ctx);58void teedev_ctx_put(struct tee_context *ctx);
59 59
60struct tee_shm *tee_shm_alloc_user_buf(struct tee_context *ctx, size_t size);60struct tee_shm *tee_shm_alloc_user_buf(struct tee_context *ctx, size_t size);
61struct tee_shm *tee_shm_register_user_buf(struct tee_context *ctx,
62 unsigned long addr, size_t length);
61 63
62#endif /*TEE_PRIVATE_H*/64#endif /*TEE_PRIVATE_H*/
drivers/tee/tee_shm.c+33−0
@@ -299,6 +299,39 @@ err: · 298 unmodified lines
299}299}
300EXPORT_SYMBOL_GPL(tee_shm_register);300EXPORT_SYMBOL_GPL(tee_shm_register);
301 301
302/**
303 * tee_shm_register_user_buf() - Register a userspace shared memory buffer
304 * @ctx: Context that registers the shared memory
305 * @addr: The userspace address of the shared buffer
306 * @length: Length of the shared buffer
307 *
308 * @returns a pointer to 'struct tee_shm'
309 */
310struct tee_shm *tee_shm_register_user_buf(struct tee_context *ctx,
311 unsigned long addr, size_t length)
312{
313 return tee_shm_register(ctx, addr, length,
314 TEE_SHM_DMA_BUF | TEE_SHM_USER_MAPPED);
315}
316
317/**
318 * tee_shm_register_kernel_buf() - Register kernel memory to be shared with
319 * secure world
320 * @ctx: Context that registers the shared memory
321 * @addr: The buffer
322 * @length: Length of the buffer
323 *
324 * @returns a pointer to 'struct tee_shm'
325 */
326
327struct tee_shm *tee_shm_register_kernel_buf(struct tee_context *ctx,
328 void *addr, size_t length)
329{
330 return tee_shm_register(ctx, (unsigned long)addr, length,
331 TEE_SHM_DMA_BUF | TEE_SHM_KERNEL_MAPPED);
332}
333EXPORT_SYMBOL_GPL(tee_shm_register_kernel_buf);
334
302static int tee_shm_fop_release(struct inode *inode, struct file *filp)335static int tee_shm_fop_release(struct inode *inode, struct file *filp)
303{336{
304 tee_shm_put(filp->private_data);337 tee_shm_put(filp->private_data);
include/linux/tee_drv.h+2−0
@@ -287,6 +287,8 @@ struct tee_shm *tee_shm_alloc_kernel_buf(struct tee_context *ctx, size_t size); · 286 unmodified lines
287 */287 */
288struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,288struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,
289 size_t length, u32 flags);289 size_t length, u32 flags);
290struct tee_shm *tee_shm_register_kernel_buf(struct tee_context *ctx,
291 void *addr, size_t length);
290 292
291/**293/**
292 * tee_shm_is_registered() - Check if shared memory object in registered in TEE294 * tee_shm_is_registered() - Check if shared memory object in registered in TEE

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t