> From: Tian, Kevin <kevin.tian@xxxxxxxxx> > Sent: Thursday, May 27, 2021 1:28 PM > /dev/ioasid provides an unified interface for managing I/O page tables for > devices assigned to userspace. Device passthrough frameworks (VFIO, vDPA, > etc.) are expected to use this interface instead of creating their own logic to > isolate untrusted device DMAs initiated by userspace. > > This proposal describes the uAPI of /dev/ioasid and also sample sequences > with VFIO as example in typical usages. The driver-facing kernel API provided > by the iommu layer is still TBD, which can be discussed after consensus is > made on this uAPI. > > It's based on a lengthy discussion starting from here: > https://lore.kernel.org/linux- > iommu/20210330132830.GO2356281@xxxxxxxxxx/ > > It ends up to be a long writing due to many things to be summarized and > non-trivial effort required to connect them into a complete proposal. > Hope it provides a clean base to converge. Thanks for the detailed RFC. Digesting it... [..] > 2.1. /dev/ioasid uAPI > +++++++++++++++++ > /* > * Register user space memory where DMA is allowed. > * > * It pins user pages and does the locked memory accounting so sub- > * sequent IOASID_MAP/UNMAP_DMA calls get faster. > * > * When this ioctl is not used, one user page might be accounted > * multiple times when it is mapped by multiple IOASIDs which are > * not nested together. > * > * Input parameters: > * - vaddr; > * - size; > * > * Return: 0 on success, -errno on failure. > */ It appears that this is only to make map ioctl faster apart from accounting. It doesn't have any ioasid handle input either. In that case, can it be a new system call? Why does it have to be under /dev/ioasid? For example few years back such system call mpin() thought was proposed in [1]. Or a new MAP_PINNED flag is better approach to achieve in single mmap() call? > #define IOASID_REGISTER_MEMORY _IO(IOASID_TYPE, IOASID_BASE + 1) > #define IOASID_UNREGISTER_MEMORY _IO(IOASID_TYPE, > IOASID_BASE + 2) [1] https://lwn.net/Articles/600502/