[PATCH v1 0/3] tests/qtest: add Intel IOMMU IOTLB invalidation test

Junjie Cao posted 3 patches 3 weeks, 2 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260703072200.463082-1-junjie.cao@intel.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowangio@gmail.com>, Yi Liu <yi.l.liu@intel.com>, "Clément Mathieu--Drif" <clement.mathieu--drif@bull.com>, Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Tao Tang <tangtao1634@phytium.com.cn>
MAINTAINERS                          |   1 +
tests/qtest/iommu-intel-inv-test.c   | 346 +++++++++++++++++++++++++++
tests/qtest/iommu-intel-test.c       |  78 +-----
tests/qtest/libqos/qos-intel-iommu.c | 185 ++++++++++++++
tests/qtest/libqos/qos-intel-iommu.h |  74 ++++++
tests/qtest/meson.build              |   2 +-
6 files changed, 608 insertions(+), 78 deletions(-)
create mode 100644 tests/qtest/iommu-intel-inv-test.c
[PATCH v1 0/3] tests/qtest: add Intel IOMMU IOTLB invalidation test
Posted by Junjie Cao 3 weeks, 2 days ago
The iommu-testdev framework lets a qtest drive an emulated vIOMMU
without a guest, and Intel translation tests already build on it [1].
The next behaviour worth covering is invalidation: no in-tree qtest
checks that any vIOMMU actually flushes a stale IOTLB entry.  This
series adds that for VT-d.

Each case populates the IOTLB (map IOVA->PA_A, DMA), rewrites the leaf
PTE to PA_B without invalidating and confirms the stale entry still
serves PA_A, then invalidates and confirms a fresh walk reaches PA_B.
Without the stale check, a device that never cached would also pass.
Cases cover {legacy, scalable-slt, scalable-flt} x {global, domain,
page}, driving vtd_process_inv_desc -> vtd_process_iotlb_desc ->
vtd_iotlb_{global,domain,page}_invalidate.  Three more cases cache a
second page to check page-selective scope: it survives for second-level
and, as QEMU flushes first-stage entries domain-wide, is evicted for
scalable-flt.

Patch 1 moves the VT-d setup helpers out of iommu-intel-test.c into the
shared qos-intel-iommu module with no functional change; patch 2 adds
the invalidation helpers; patch 3 adds the test.

scalable-flt uses the legacy VTD_INV_DESC_IOTLB descriptor, the path
QEMU runs for its unified IOTLB; PASID-selective PIOTLB and domain-level
selectivity are left as follow-ups.

[1] https://lore.kernel.org/qemu-devel/cover.1774421649.git.15fengyuan@gmail.com/

Junjie Cao (3):
  tests/qtest/libqos: share Intel IOMMU test setup helpers
  tests/qtest/libqos: add Intel IOMMU invalidation helpers
  tests/qtest: add IOTLB invalidation test for Intel IOMMU

 MAINTAINERS                          |   1 +
 tests/qtest/iommu-intel-inv-test.c   | 346 +++++++++++++++++++++++++++
 tests/qtest/iommu-intel-test.c       |  78 +-----
 tests/qtest/libqos/qos-intel-iommu.c | 185 ++++++++++++++
 tests/qtest/libqos/qos-intel-iommu.h |  74 ++++++
 tests/qtest/meson.build              |   2 +-
 6 files changed, 608 insertions(+), 78 deletions(-)
 create mode 100644 tests/qtest/iommu-intel-inv-test.c


base-commit: b4bdad7dcef623d2874df4e79e0be01075096c3b
-- 
2.43.0