History

tee: new ioctl to a register tee_shm from a dmabuf file descriptor

Add a userspace API to create a tee_shm object that refers to a dmabuf reference. Userspace registers the dmabuf file descriptor as in a tee_shm object. The registration is completed with a tee_shm returned file descriptor. Userspace is free to close the dmabuf file descriptor after it has been registered since all the resources are now held via the new tee_shm object. Closing the tee_shm file descriptor will eventually release all resources used by the tee_shm object when all references are released. The new IOCTL, TEE_IOC_SHM_REGISTER_FD, supports dmabuf references to physically contiguous memory buffers. Dmabuf references acquired from the TEE DMA-heap can be used as protected memory for Secure Video Path and such use cases. It depends on the TEE and the TEE driver if dmabuf references acquired by other means can be used. A new tee_shm flag is added to identify tee_shm objects built from a registered dmabuf, TEE_SHM_DMA_BUF.

Etienne Carriere committed 1 year ago

Commit 146bf4e1 parent fdf631a6 files · +182 −4Browse files

Showing the changes to include/uapi (1 of 6 files). Show all

Unified · Split

include/uapi/linux/tee.h+31−0
@@ -378,6 +378,37 @@ struct tee_ioctl_shm_register_data { · 377 unmodified lines
378378 __s32 id;
379379 };
380380
381+/**
382+ * struct tee_ioctl_shm_register_fd_data - Shared memory registering argument
383+ * @fd: [in] File descriptor identifying dmabuf reference
384+ * @size: [out] Size of referenced memory
385+ * @flags: [in] Flags to/from allocation.
386+ * @id: [out] Identifier of the shared memory
387+ *
388+ * The flags field should currently be zero as input. Updated by the call
389+ * with actual flags as defined by TEE_IOCTL_SHM_* above.
390+ * This structure is used as argument for TEE_IOC_SHM_REGISTER_FD below.
391+ */
392+struct tee_ioctl_shm_register_fd_data {
393+ __s64 fd;
394+ __u64 size;
395+ __u32 flags;
396+ __s32 id;
397+};
398+
399+/**
400+ * TEE_IOC_SHM_REGISTER_FD - register a shared memory from a file descriptor
401+ *
402+ * Returns a file descriptor on success or < 0 on failure
403+ *
404+ * The returned file descriptor refers to the shared memory object in the
405+ * kernel. The supplied file deccriptor can be closed if it's not needed
406+ * for other purposes. The shared memory is freed when the descriptor is
407+ * closed.
408+ */
409+#define TEE_IOC_SHM_REGISTER_FD _IOWR(TEE_IOC_MAGIC, TEE_IOC_BASE + 8, \
410+ struct tee_ioctl_shm_register_fd_data)
411+
381412 /**
382413 * TEE_IOC_SHM_REGISTER - Register shared memory argument
383414 *