···8989 .mmap = tee_shm_op_mmap,9090};91919292-static struct tee_shm *__tee_shm_alloc(struct tee_context *ctx,9393- struct tee_device *teedev,9494- size_t size, u32 flags)9292+struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags)9593{9494+ struct tee_device *teedev = ctx->teedev;9695 struct tee_shm_pool_mgr *poolm = NULL;9796 struct tee_shm *shm;9897 void *ret;9998 int rc;100100-101101- if (ctx && ctx->teedev != teedev) {102102- dev_err(teedev->dev.parent, "ctx and teedev mismatch\n");103103- return ERR_PTR(-EINVAL);104104- }10599106100 if (!(flags & TEE_SHM_MAPPED)) {107101 dev_err(teedev->dev.parent,···176182 tee_device_put(teedev);177183 return ret;178184}179179-180180-/**181181- * tee_shm_alloc() - Allocate shared memory182182- * @ctx: Context that allocates the shared memory183183- * @size: Requested size of shared memory184184- * @flags: Flags setting properties for the requested shared memory.185185- *186186- * Memory allocated as global shared memory is automatically freed when the187187- * TEE file pointer is closed. The @flags field uses the bits defined by188188- * TEE_SHM_* in <linux/tee_drv.h>. TEE_SHM_MAPPED must currently always be189189- * set. If TEE_SHM_DMA_BUF global shared memory will be allocated and190190- * associated with a dma-buf handle, else driver private memory.191191- */192192-struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags)193193-{194194- return __tee_shm_alloc(ctx, ctx->teedev, size, flags);195195-}196185EXPORT_SYMBOL_GPL(tee_shm_alloc);197197-198198-struct tee_shm *tee_shm_priv_alloc(struct tee_device *teedev, size_t size)199199-{200200- return __tee_shm_alloc(NULL, teedev, size, TEE_SHM_MAPPED);201201-}202202-EXPORT_SYMBOL_GPL(tee_shm_priv_alloc);203186204187struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,205188 size_t length, u32 flags)
-12
include/linux/tee_drv.h
···316316struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags);317317318318/**319319- * tee_shm_priv_alloc() - Allocate shared memory privately320320- * @dev: Device that allocates the shared memory321321- * @size: Requested size of shared memory322322- *323323- * Allocates shared memory buffer that is not associated with any client324324- * context. Such buffers are owned by TEE driver and used for internal calls.325325- *326326- * @returns a pointer to 'struct tee_shm'327327- */328328-struct tee_shm *tee_shm_priv_alloc(struct tee_device *teedev, size_t size);329329-330330-/**331319 * tee_shm_register() - Register shared memory buffer332320 * @ctx: Context that registers the shared memory333321 * @addr: Address is userspace of the shared buffer