Hi, When svm=on,pasid-bits=N,fsts=on is configured for virtual vtd, we enable guest's support for vSVM. In this case, the host VTD may generate recoverable first stage page fault event, QEMU read the event and inject it to guest.
After guest handles the event, it sends a page group response, QEMU gets the response and pass it to host VTD. This series adds QEMU support for receiving such host events through the FAULTQ interface and propagating them to the guest, then catching guest's responses and propagating them to host. GIT branch: https://github.com/yiliu1765/qemu/tree/zhenzhong/iommufd_prq.v6 Tests: Tested with DSA wq attached to an user APP which triggers IO page fault on process page table durging DMA. Build test with window cross-build. Thanks Zhenzhong Changelog: v6: - further polish doc comments for vtd_pri_request_page (Liuyi) - set FAULTQ_BUF_SIZE to 2048 to avoid prq lost (Liuyi) - move PRE validation hunk in the caller side (Liuyi) - add break in vtd_prq_list search loop in vtd_prq_response_notify (Clement) - s/vtd_prq_report_fault/vtd_propagate_recoverable_fault (Liuyi, Clement) - s/vtd_prq_read_fault/vtd_read_fs_faultq (Liuyi) - s/vtd_prq_write_response/vtd_write_fs_faultq - s/vtd_prq_response_notify/vtd_prq_handle_pasid_response v5: - add comment "Accept the PCI PASID as input" to docstring of function vtd_pri_request_page (Clement) - change vtd_prq_report_fault() parameter type "int cnt" -> "unsigned cnt" (Clement) - check return value of vtd_pri_request_page() and send response (Clement) - free all vtd_prq_list entries when detaching (Clement) v4: - add the comment to the docstring of the function vtd_prq_report_fault itself (Clement) - add "out_" prefix for fault_id & fault_fd output parameter (Clement) v3: - convert to PCI pasid before passing to vtd_pri_request_page (Clement) - expose vtd_pri_request_page and drop accel_ops pointer (Clement) - add a cleanup patch "intel_iommu_accel: Guard VTDAccelPASIDCacheEntry definition" (Philippe) v2: - define fault_fd int type (Liuyi) - update comments on FAULTQ_BUF_SIZE (Liuyi) - drop param vtd_hiod in vtd_destroy_old_fs_faultq() (Liuyi) - s/vtd_propagate_page_group_response_accel/vtd_accel_propagate_page_group_response (Liuyi) - call vtd_prq_response_notify() directly instead of through pri_notifier (Liuyi) - replace "fault_id != 0" check with "fault_fd < 0" check (Liuyi) Zhenzhong Duan (6): intel_iommu_accel: Guard VTDAccelPASIDCacheEntry definition backends/iommufd: Introduce iommufd_backend_alloc_faultq backends/iommufd: Extend iommufd_backend_alloc_hwpt() with fault_id intel_iommu_accel: Add PRQ injection for passthrough device intel_iommu_accel: Accept PRQ response for passthrough device intel_iommu_accel: teardown FAULTQ resources in bottom half hw/i386/intel_iommu_accel.h | 16 +- hw/i386/intel_iommu_internal.h | 3 + include/hw/i386/intel_iommu.h | 6 + include/system/iommufd.h | 7 +- backends/iommufd.c | 28 +++- hw/arm/smmuv3-accel.c | 6 +- hw/i386/intel_iommu.c | 18 ++- hw/i386/intel_iommu_accel.c | 281 ++++++++++++++++++++++++++++++++- hw/vfio/iommufd.c | 2 +- backends/trace-events | 3 +- hw/i386/trace-events | 2 + 11 files changed, 350 insertions(+), 22 deletions(-) -- 2.52.0
