@samitouri / QOSamiQemu / commits / dde3f966f0

intel_iommu: Fix PASID validity check in fault reporting

The current code incorrectly uses "pasid != PCI_NO_PASID" to determine if PASID should be reported in fault records. However, this check happens after the code converts PCI_NO_PASID to PASID_0 in scalable mode. This means that for requests that originally had PCI_NO_PASID, the check "pasid != PCI_NO_PASID" will incorrectly return true (since pasid is now PASID_0), causing fault records to incorrectly indicate PASID validity. According to the VT-d specification, the PASID field in fault records is only valid for Requests-with-PASID: "When Set, indicates the faulted request has a PASID TLP Prefix." Fix this by capturing the original PASID state before the PCI_NO_PASID to PASID_0 conversion, ensuring fault records correctly reflect whether the original request had a PASID. Fixes: 1b2b12376c8a ("intel_iommu: process PASID-based iotlb invalidation") Suggested-by: Yi Liu <yi.l.liu@intel.com> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260527054658.1021096-9-zhenzhong.duan@intel.com> Reviewed-by: Clement Mathieu--Drif <clement.mathieu--drif@bull.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Zhenzhong Duan committed May 27, 2026 at 01:46 UTC dde3f966f0fe57fa29af664d9c9cab290f3c00bb
1 file changed +2 -1
hw/i386/intel_iommu.c
+2 -1
@@ -2109,6 +2109,7 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus,
2109 bool is_fpd_set = false;
2110 bool reads = true;
2111 bool writes = true;
2112 + bool is_pasid = pasid != PCI_NO_PASID;
2113 uint8_t access_flags, pgtt;
2114 VTDIOTLBEntry *iotlb_entry;
2115 uint64_t xlat, size;
@@ -2235,7 +2236,7 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus,
2236 if (ret_fr) {
2237 if (!vtd_is_recoverable_fault(-ret_fr, iommu_idx)) {
2238 vtd_report_fault(s, -ret_fr, is_fpd_set, source_id,
2238 - addr, is_write, pasid != PCI_NO_PASID, pasid);
2239 + addr, is_write, is_pasid, pasid);
2240 }
2241 goto error;
2242 }