soc: qcom: mem-buf: Add support for suppliers to export dma-bufs

Currently, mem-buf suppliers can only provide a consumer with a memory
buffer if the consumer requests for the memory buffer, in which case
the supplier has no control over the contents of the buffer that is
given to the consumer. This is not ideal in cases where the supplier
virtual machine (VM) may have data that is of interest to the consumer,
which can be shared using a memory buffer.

Introduce a new IOCTL command which allows a client to specify a
dma-buf that they would like to share with a consumer VM, as well
as the access control rules that should be applied to the buffer.

Change-Id: I1e4ec1205ad4e69039ec0ab26b4209512896a354
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
This commit is contained in:
Isaac J. Manjarres 2020-05-19 16:00:50 -07:00
commit 50c067fc65
2 changed files with 375 additions and 21 deletions

View file

@ -97,4 +97,38 @@ struct mem_buf_alloc_ioctl_arg {
#define MEM_BUF_IOC_ALLOC _IOWR(MEM_BUF_IOC_MAGIC, 0,\
struct mem_buf_alloc_ioctl_arg)
/**
* struct mem_buf_export_ioctl_arg: An request to allocate memory from another
* VM to other VMs.
* @dma_buf_fd: The fd of the dma-buf that will be exported to another VM.
* @nr_acl_entries: The number of ACL entries in @acl_list.
* @acl_list: An array of structures, where each structure specifies a VMID
* and the access permissions that the VMID will have to the memory to be
* exported.
* @export_fd: An fd that corresponds to the buffer that was exported. This fd
* must be kept open until it is no longer required to export the memory to
* another VM.
* @memparcel_hdl: The handle associated with the memparcel that was created by
* granting access to the dma-buf for the VMIDs specified in @acl_list.
*
* Note: The buffer must not be mmap'ed by any process prior to invoking this
* IOCTL. The buffer must also be a cached buffer from a non-secure ION heap.
*
* All reserved fields must be zeroed out by the caller prior to invoking the
* export IOCTL command with this argument.
*/
struct mem_buf_export_ioctl_arg {
__u32 dma_buf_fd;
__u32 nr_acl_entries;
__u64 acl_list;
__u32 export_fd;
__u32 memparcel_hdl;
__u64 reserved0;
__u64 reserved1;
__u64 reserved2;
};
#define MEM_BUF_IOC_EXPORT _IOWR(MEM_BUF_IOC_MAGIC, 1,\
struct mem_buf_export_ioctl_arg)
#endif /* _UAPI_LINUX_MEM_BUF_H */