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.v4 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: 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 | 11 +- hw/i386/intel_iommu_accel.c | 252 ++++++++++++++++++++++++++++++++- hw/vfio/iommufd.c | 2 +- backends/trace-events | 3 +- hw/i386/trace-events | 2 + 11 files changed, 315 insertions(+), 21 deletions(-) -- 2.52.0
