History

iommufd: Add iommufd fault object

An iommufd fault object provides an interface for delivering I/O page faults to user space. These objects are created and destroyed by user space, and they can be associated with or dissociated from hardware page table objects during page table allocation or destruction. User space interacts with the fault object through a file interface. This interface offers a straightforward and efficient way for user space to handle page faults. It allows user space to read fault messages sequentially and respond to them by writing to the same file. The file interface supports reading messages in poll mode, so it's recommended that user space applications use io_uring to enhance read and write efficiency. A fault object can be associated with any iopf-capable iommufd_hw_pgtable during the pgtable's allocation. All I/O page faults triggered by devices when accessing the I/O addresses of an iommufd_hw_pgtable are routed through the fault object to user space. Similarly, user space's responses to these page faults are routed back to the iommu device driver through the same fault object.

Lu Baolu committed 2 years ago

Commit 07838f71 parent c714f157 files · +287 −0Browse files

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

Unified · Split

include/uapi/linux/iommufd.h+18−0
@@ -50,6 +50,7 @@ enum { · 49 unmodified lines
50 IOMMUFD_CMD_HWPT_SET_DIRTY_TRACKING,50 IOMMUFD_CMD_HWPT_SET_DIRTY_TRACKING,
51 IOMMUFD_CMD_HWPT_GET_DIRTY_BITMAP,51 IOMMUFD_CMD_HWPT_GET_DIRTY_BITMAP,
52 IOMMUFD_CMD_HWPT_INVALIDATE,52 IOMMUFD_CMD_HWPT_INVALIDATE,
53 IOMMUFD_CMD_FAULT_QUEUE_ALLOC,
53};54};
54 55
55/**56/**
@@ -775,4 +776,21 @@ struct iommu_hwpt_page_response { · 719 unmodified lines
775 __u32 cookie;776 __u32 cookie;
776 __u32 code;777 __u32 code;
777};778};
779
780/**
781 * struct iommu_fault_alloc - ioctl(IOMMU_FAULT_QUEUE_ALLOC)
782 * @size: sizeof(struct iommu_fault_alloc)
783 * @flags: Must be 0
784 * @out_fault_id: The ID of the new FAULT
785 * @out_fault_fd: The fd of the new FAULT
786 *
787 * Explicitly allocate a fault handling object.
788 */
789struct iommu_fault_alloc {
790 __u32 size;
791 __u32 flags;
792 __u32 out_fault_id;
793 __u32 out_fault_fd;
794};
795#define IOMMU_FAULT_QUEUE_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_FAULT_QUEUE_ALLOC)
778#endif796#endif