Skip to contentSkip to conversation

VT-d minor fixes

PATCH Superseded CLEMENT MATHIEU--DRIF 1 participant 4 messages Jul 4, 2024

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover VT-d minor fixes

From: Clement Mathieu--Drif <[email protected]>

Various fixes for VT-d

This series contains fixes that will be necessary when adding in-guest (fully emulated) SVM support.

Clement Mathieu--Drif (2):
intel_iommu: make types match
intel_iommu: Bypass barrier wait descriptor

Clément Mathieu--Drif (1):
intel_iommu: fix FRCD construction macro.

 hw/i386/intel_iommu.c          | 8 +++++++-
 hw/i386/intel_iommu_internal.h | 4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)
Signature · 1 line
2.45.2
#1 lore raw

PATCH 1/3 intel_iommu: fix FRCD construction macro.

From: Clément Mathieu--Drif <[email protected]>

The constant must be unsigned, otherwise the two's complement overrides the other fields when a PASID is present

Fixes 1b2b12376c ("intel-iommu: PASID support")
---
 hw/i386/intel_iommu_internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/intel_iommu_internal.h +1 -1
index f8cf99bddf..cbc4030031 100644
@@ -267,7 +267,7 @@
 /* For the low 64-bit of 128-bit */
 #define VTD_FRCD_FI(val)        ((val) & ~0xfffULL)
 #define VTD_FRCD_PV(val)        (((val) & 0xffffULL) << 40)
-#define VTD_FRCD_PP(val)        (((val) & 0x1) << 31)
+#define VTD_FRCD_PP(val)        (((val) & 0x1ULL) << 31)
 #define VTD_FRCD_IR_IDX(val)    (((val) & 0xffffULL) << 48)
 
 /* DMA Remapping Fault Conditions */
Signature · 1 line
2.45.2
#2 lore raw

PATCH 2/3 intel_iommu: make types match

In reply to CLEMENT MATHIEU--DRIF

From: Clement Mathieu--Drif <[email protected]>

The 'level' field in vtd_iotlb_key is an unsigned integer. We don't need to store level as an int in vtd_lookup_iotlb.

VTDIOTLBPageInvInfo.mask is used in binary operations with addresses.

---
 hw/i386/intel_iommu.c          | 2 +-
 hw/i386/intel_iommu_internal.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
hw/i386/intel_iommu.c +1 -1
index 37c21a0aec..be0cb39b5c 100644
@@ -358,7 +358,7 @@ static VTDIOTLBEntry *vtd_lookup_iotlb(IntelIOMMUState *s, uint16_t source_id,
 {
     struct vtd_iotlb_key key;
     VTDIOTLBEntry *entry;
-    int level;
+    unsigned level;
 
     for (level = VTD_SL_PT_LEVEL; level < VTD_SL_PML4_LEVEL; level++) {
         key.gfn = vtd_get_iotlb_gfn(addr, level);
hw/i386/intel_iommu_internal.h +1 -1
index cbc4030031..5fcbe2744f 100644
@@ -436,7 +436,7 @@ struct VTDIOTLBPageInvInfo {
     uint16_t domain_id;
     uint32_t pasid;
     uint64_t addr;
-    uint8_t mask;
+    uint64_t mask;
 };
 typedef struct VTDIOTLBPageInvInfo VTDIOTLBPageInvInfo;
 
Signature · 1 line
2.45.2
#3 lore raw

PATCH 3/3 intel_iommu: Bypass barrier wait descriptor

In reply to CLEMENT MATHIEU--DRIF

From: Clement Mathieu--Drif <[email protected]>

wait_desc with SW=0,IF=0,FN=1 must not be considered as an invalid descriptor as it is used to implement section 7.10 of the VT-d spec

---
 hw/i386/intel_iommu.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/i386/intel_iommu.c +6 -0
index be0cb39b5c..12ea3a9aa0 100644
@@ -2561,6 +2561,12 @@ static bool vtd_process_wait_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc)
     } else if (inv_desc->lo & VTD_INV_DESC_WAIT_IF) {
         /* Interrupt flag */
         vtd_generate_completion_event(s);
+    } else if (inv_desc->lo & VTD_INV_DESC_WAIT_FN) {
+        /*
+         * SW = 0, IF = 0, FN = 1
+         * This kind of descriptor is defined in section 7.10 of VT-d
+         * Nothing to do as we process the events sequentially
+         */
     } else {
         error_report_once("%s: invalid wait desc: hi=%"PRIx64", lo=%"PRIx64
                           " (unknown type)", __func__, inv_desc->hi,
Signature · 1 line
2.45.2