@samitouri / QOSamiQemu / commits / db2bc1f335

intel_iommu: make vtd_dev_get_pe_from_pasid() more generic

Refactor vtd_dev_get_pe_from_pasid() to take individual parameters (IntelIOMMUState, PCIBus, devfn, pasid) instead of VTDAddressSpace. This makes the function more reusable and prepares it for export to be used in the acceleration path. Remove inline qualifier as the function will be exported in a subsequent patch. No functional changes intended. 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-7-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 db2bc1f3353c32e011bb6dbec675228cb1410fbe
1 file changed +7 -7
hw/i386/intel_iommu.c
+7 -7
@@ -3113,10 +3113,10 @@ static bool vtd_process_piotlb_desc(IntelIOMMUState *s,
3113 return true;
3114 }
3115
3116 -static inline int vtd_dev_get_pe_from_pasid(VTDAddressSpace *vtd_as,
3117 - VTDPASIDEntry *pe)
3116 +static int vtd_dev_get_pe_from_pasid(IntelIOMMUState *s, PCIBus *bus,
3117 + uint8_t devfn, uint32_t pasid,
3118 + VTDPASIDEntry *pe)
3119 {
3119 - IntelIOMMUState *s = vtd_as->iommu_state;
3120 VTDContextEntry ce;
3121 int ret;
3122
@@ -3124,13 +3124,12 @@ static inline int vtd_dev_get_pe_from_pasid(VTDAddressSpace *vtd_as,
3124 return -VTD_FR_RTADDR_INV_TTM;
3125 }
3126
3127 - ret = vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus), vtd_as->devfn,
3128 - &ce);
3127 + ret = vtd_dev_to_context_entry(s, pci_bus_num(bus), devfn, &ce);
3128 if (ret) {
3129 return ret;
3130 }
3131
3133 - return vtd_ce_get_pasid_entry(s, &ce, pe, vtd_as->pasid);
3132 + return vtd_ce_get_pasid_entry(s, &ce, pe, pasid);
3133 }
3134
3135 static int vtd_pasid_entry_compare(VTDPASIDEntry *p1, VTDPASIDEntry *p2)
@@ -3151,7 +3150,8 @@ static void vtd_pasid_cache_sync_locked(gpointer key, gpointer value,
3150 const char *err_prefix = "Attaching to HWPT failed: ";
3151 Error *local_err = NULL;
3152
3154 - if (vtd_dev_get_pe_from_pasid(vtd_as, &pe)) {
3153 + if (vtd_dev_get_pe_from_pasid(vtd_as->iommu_state, vtd_as->bus,
3154 + vtd_as->devfn, vtd_as->pasid, &pe)) {
3155 if (!pc_entry->valid) {
3156 return;
3157 }