On Mon, Jan 22, 2024 at 03:39:00PM +0800, Lu Baolu wrote: > @@ -411,6 +414,8 @@ enum iommu_hwpt_data_type { > * @__reserved: Must be 0 > * @data_type: One of enum iommu_hwpt_data_type > * @data_len: Length of the type specific data > + * @fault_id: The ID of IOMMUFD_FAULT object. Valid only if flags field of > + * IOMMU_HWPT_FAULT_ID_VALID is set. > * @data_uptr: User pointer to the type specific data > * > * Explicitly allocate a hardware page table object. This is the same object > @@ -441,6 +446,7 @@ struct iommu_hwpt_alloc { > __u32 __reserved; > __u32 data_type; > __u32 data_len; > + __u32 fault_id; > __aligned_u64 data_uptr; > }; ?? We can't add fault_id in the middle of the struct?? > + if (cmd->flags & IOMMU_HWPT_FAULT_ID_VALID) { > + struct iommufd_fault *fault; > + > + fault = iommufd_get_fault(ucmd, cmd->fault_id); > + if (IS_ERR(fault)) { > + rc = PTR_ERR(fault); > + goto out_hwpt; > + } > + hwpt->fault = fault; > + hwpt->domain->iopf_handler = iommufd_fault_iopf_handler; > + hwpt->domain->fault_data = hwpt; > + hwpt->fault_capable = true; I wonder if there should be an iommu API to make a domain fault capable? Jason