[PATCH v5 0/6] intel_iommu: Enable PRQ support for passthrough device

Zhenzhong Duan posted 6 patches 3 weeks, 5 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260831095200.1279366-1-zhenzhong.duan@intel.com
Maintainers: Yi Liu <yi.l.liu@intel.com>, Eric Auger <eric.auger@redhat.com>, Zhenzhong Duan <zhenzhong.duan@intel.com>, Peter Maydell <peter.maydell@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowangio@gmail.com>, "Clément Mathieu--Drif" <clement.mathieu--drif@bull.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Alex Williamson <alex@shazbot.org>, "Cédric Le Goater" <clg@redhat.com>
There is a newer version of this series
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          |  13 +-
hw/i386/intel_iommu_accel.c    | 278 ++++++++++++++++++++++++++++++++-
hw/vfio/iommufd.c              |   2 +-
backends/trace-events          |   3 +-
hw/i386/trace-events           |   2 +
11 files changed, 342 insertions(+), 22 deletions(-)
[PATCH v5 0/6] intel_iommu: Enable PRQ support for passthrough device
Posted by Zhenzhong Duan 3 weeks, 5 days ago
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.v5

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:
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          |  13 +-
 hw/i386/intel_iommu_accel.c    | 278 ++++++++++++++++++++++++++++++++-
 hw/vfio/iommufd.c              |   2 +-
 backends/trace-events          |   3 +-
 hw/i386/trace-events           |   2 +
 11 files changed, 342 insertions(+), 22 deletions(-)

-- 
2.52.0
Re: [PATCH v5 0/6] intel_iommu: Enable PRQ support for passthrough device
Posted by Clément MATHIEU--DRIF 3 weeks, 3 days ago
Hi Zhenzhong,

Thanks for the respin, I will try to review it by the end of the week.

I will also send a patch soon to make PRI thread safe.

cmd

On Mon, 2026-08-31 at 17:51 +0800, Zhenzhong Duan wrote:
> Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.
> 
> 
> 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.v5](https://github.com/yiliu1765/qemu/tree/zhenzhong/iommufd_prq.v5)
> 
> 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:  
> 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          |  13 +-  
>  hw/i386/intel_iommu_accel.c    | 278 ++++++++++++++++++++++++++++++++-  
>  hw/vfio/iommufd.c              |   2 +-  
>  backends/trace-events          |   3 +-  
>  hw/i386/trace-events           |   2 +  
>  11 files changed, 342 insertions(+), 22 deletions(-)
> 
> --  
> 2.52.0
>