intel_iommu: Use IOMMU_NO_PASID and delete PASID_0
In previous patch we introduced a global macro IOMMU_NO_PASID(0) for the RID attachment, this makes the local macro PASID_0 redundant. Delete it and use IOMMU_NO_PASID instead. No functional changes intended. Suggested-by: Yi Liu <yi.l.liu@intel.com> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Reviewed-by: Yi Liu <yi.l.liu@intel.com> Reviewed-by: Clement Mathieu--Drif <clement.mathieu--drif@bull.com> Tested-by: Xudong Hao <xudong.hao@intel.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260527054658.1021096-10-zhenzhong.duan@intel.com>
Zhenzhong Duan committed
May 27, 2026 at 01:46 UTC
6c4467745c27676e8bda6d9eb0bb2a70d2a7bca6
3 files changed
+12
-13
hw/i386/intel_iommu.c
+11
-11
@@ -941,7 +941,7 @@ static int vtd_ce_get_pasid_entry(IntelIOMMUState *s, VTDContextEntry *ce,
941
dma_addr_t pasid_dir_base;
942
943
if (pasid == PCI_NO_PASID) {
944
- pasid = PASID_0;
944
+ pasid = IOMMU_NO_PASID;
945
}
946
pasid_dir_base = VTD_CE_GET_PASID_DIR_TABLE(ce);
947
return vtd_get_pe_from_pasid_table(s, pasid_dir_base, pasid, pe);
@@ -958,7 +958,7 @@ static int vtd_ce_get_pasid_fpd(IntelIOMMUState *s,
958
VTDPASIDEntry pe;
959
960
if (pasid == PCI_NO_PASID) {
961
- pasid = PASID_0;
961
+ pasid = IOMMU_NO_PASID;
962
}
963
pasid_dir_base = VTD_CE_GET_PASID_DIR_TABLE(ce);
964
@@ -1501,9 +1501,9 @@ static int vtd_ce_pasid_0_check(IntelIOMMUState *s, VTDContextEntry *ce)
1501
1502
/*
1503
* Make sure in Scalable Mode, a present context entry
1504
- * has valid pasid entry setting at PASID_0.
1504
+ * has valid pasid entry setting at IOMMU_NO_PASID.
1505
*/
1506
- return vtd_ce_get_pasid_entry(s, ce, &pe, PASID_0);
1506
+ return vtd_ce_get_pasid_entry(s, ce, &pe, IOMMU_NO_PASID);
1507
}
1508
1509
/* Map a device to its corresponding domain (context-entry) */
@@ -1564,7 +1564,7 @@ int vtd_dev_to_context_entry(IntelIOMMUState *s, uint8_t bus_num,
1564
}
1565
} else {
1566
/*
1567
- * Check if the programming of pasid setting of PASID_0
1567
+ * Check if the programming of pasid setting of IOMMU_NO_PASID
1568
* is valid, and thus avoids to check pasid entry fetching
1569
* result in future helper function calling.
1570
*/
@@ -2123,7 +2123,7 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus,
2123
vtd_iommu_lock(s);
2124
2125
if (pasid == PCI_NO_PASID && s->root_scalable) {
2126
- pasid = PASID_0;
2126
+ pasid = IOMMU_NO_PASID;
2127
}
2128
2129
/* Try to fetch pte from IOTLB */
@@ -2488,7 +2488,7 @@ static void vtd_iotlb_domain_invalidate(IntelIOMMUState *s, uint16_t domain_id)
2488
}
2489
2490
/*
2491
- * There is no pasid field in iotlb invalidation descriptor, so PCI_NO_PASID
2491
+ * There is no pasid field in iotlb invalidation descriptor, so IOMMU_NO_PASID
2492
* is passed as parameter. Piotlb invalidation supports pasid, pasid in its
2493
* descriptor is passed which should not be PCI_NO_PASID.
2494
*/
@@ -2509,10 +2509,10 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s,
2509
* In legacy mode, vtd_as->pasid == pasid is always true.
2510
* In scalable mode, for vtd address space backing a PCI
2511
* device without pasid, needs to compare pasid with
2512
- * PASID_0 of this device.
2512
+ * IOMMU_NO_PASID of this device.
2513
*/
2514
if (!(vtd_as->pasid == pasid ||
2515
- (vtd_as->pasid == PCI_NO_PASID && pasid == PASID_0))) {
2515
+ (vtd_as->pasid == PCI_NO_PASID && pasid == IOMMU_NO_PASID))) {
2516
continue;
2517
}
2518
@@ -2564,7 +2564,7 @@ static void vtd_iotlb_page_invalidate(IntelIOMMUState *s, uint16_t domain_id,
2564
vtd_iommu_lock(s);
2565
g_hash_table_foreach_remove(s->iotlb, vtd_hash_remove_by_page, &info);
2566
vtd_iommu_unlock(s);
2567
- vtd_iotlb_page_invalidate_notify(s, domain_id, addr, am, PCI_NO_PASID);
2567
+ vtd_iotlb_page_invalidate_notify(s, domain_id, addr, am, IOMMU_NO_PASID);
2568
}
2569
2570
/* Flush IOTLB
@@ -3023,7 +3023,7 @@ static void vtd_piotlb_pasid_invalidate(IntelIOMMUState *s,
3023
if (!vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus),
3024
vtd_as->devfn, &ce) &&
3025
domain_id == vtd_get_domain_id(s, &ce, vtd_as->pasid)) {
3026
- if ((vtd_as->pasid != PCI_NO_PASID || pasid != PASID_0) &&
3026
+ if ((vtd_as->pasid != PCI_NO_PASID || pasid != IOMMU_NO_PASID) &&
3027
vtd_as->pasid != pasid) {
3028
continue;
3029
}
hw/i386/intel_iommu_accel.c
+1
-1
@@ -217,7 +217,7 @@ static void vtd_flush_host_piotlb_locked(gpointer key, gpointer value,
217
218
did = VTD_SM_PASID_ENTRY_DID(&pc_entry->pasid_entry);
219
220
- if (piotlb_info->domain_id == did && piotlb_info->pasid == PASID_0) {
220
+ if (piotlb_info->domain_id == did && piotlb_info->pasid == IOMMU_NO_PASID) {
221
HostIOMMUDeviceIOMMUFD *hiodi =
222
HOST_IOMMU_DEVICE_IOMMUFD(vtd_hiod->hiod);
223
uint32_t entry_num = 1; /* Only implement one request for simplicity */
hw/i386/intel_iommu_internal.h
-1
@@ -615,7 +615,6 @@ typedef struct VTDRootEntry VTDRootEntry;
615
#define VTD_CTX_ENTRY_LEGACY_SIZE 16
616
#define VTD_CTX_ENTRY_SCALABLE_SIZE 32
617
618
-#define PASID_0 0
618
#define VTD_SM_CONTEXT_ENTRY_RSVD_VAL0(aw) (0x1e0ULL | ~VTD_HAW_MASK(aw))
619
#define VTD_SM_CONTEXT_ENTRY_RSVD_VAL1 0xffffffffffe00000ULL
620
#define VTD_SM_CONTEXT_ENTRY_PRE 0x10ULL