100 lines
4.4 KiB
Diff
100 lines
4.4 KiB
Diff
|
|
From 9ce9ecae9d7cf59554908787386901dd82fd7395 Mon Sep 17 00:00:00 2001
|
||
|
|
From: guping <guping_yewu@cmss.chinamobile.com>
|
||
|
|
Date: Wed, 9 Oct 2024 09:21:03 +0800
|
||
|
|
Subject: [PATCH] intel_iommu: Fix invalidation descriptor type field
|
||
|
|
MIME-Version: 1.0
|
||
|
|
Content-Type: text/plain; charset=UTF-8
|
||
|
|
Content-Transfer-Encoding: 8bit
|
||
|
|
|
||
|
|
cherry-pick from 663168943d3db6d9b51d3dfa0998848a6e6eda71
|
||
|
|
|
||
|
|
According to spec, invalidation descriptor type is 7bits which is
|
||
|
|
concatenation of bits[11:9] and bits[3:0] of invalidation descriptor.
|
||
|
|
|
||
|
|
Currently we only pick bits[3:0] as the invalidation type and treat
|
||
|
|
bits[11:9] as reserved zero. This is not a problem for now as bits[11:9]
|
||
|
|
is zero for all current invalidation types. But it will break if newer
|
||
|
|
type occupies bits[11:9].
|
||
|
|
|
||
|
|
Fix it by taking bits[11:9] into type and make reserved bits check accurate.
|
||
|
|
|
||
|
|
Suggested-by: default avatarClément <Mathieu--Drif<clement.mathieu--drif@eviden.com>
|
||
|
|
Signed-off-by: default avatarZhenzhong Duan <zhenzhong.duan@intel.com>
|
||
|
|
Reviewed-by: default avatarYi Liu <yi.l.liu@intel.com>
|
||
|
|
Reviewed-by: default avatarClément <Mathieu--Drif<clement.mathieu--drif@eviden.com>
|
||
|
|
Message-Id: <20240814071321.2621384-2-zhenzhong.duan@intel.com>
|
||
|
|
Reviewed-by: MST's avatarMichael S. Tsirkin <mst@redhat.com>
|
||
|
|
Signed-off-by: MST's avatarMichael S. Tsirkin <mst@redhat.com>
|
||
|
|
Signed-off-by: guping <guping_yewu@cmss.chinamobile.com>
|
||
|
|
---
|
||
|
|
hw/i386/intel_iommu.c | 2 +-
|
||
|
|
hw/i386/intel_iommu_internal.h | 11 ++++++-----
|
||
|
|
2 files changed, 7 insertions(+), 6 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
|
||
|
|
index 2d5ad84149..2f8bcc1557 100644
|
||
|
|
--- a/hw/i386/intel_iommu.c
|
||
|
|
+++ b/hw/i386/intel_iommu.c
|
||
|
|
@@ -2502,7 +2502,7 @@ static bool vtd_process_inv_desc(IntelIOMMUState *s)
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
- desc_type = inv_desc.lo & VTD_INV_DESC_TYPE;
|
||
|
|
+ desc_type = VTD_INV_DESC_TYPE(inv_desc.lo);
|
||
|
|
/* FIXME: should update at first or at last? */
|
||
|
|
s->iq_last_desc_type = desc_type;
|
||
|
|
|
||
|
|
diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h
|
||
|
|
index a6c788049b..2b2f0dd848 100644
|
||
|
|
--- a/hw/i386/intel_iommu_internal.h
|
||
|
|
+++ b/hw/i386/intel_iommu_internal.h
|
||
|
|
@@ -340,7 +340,8 @@ union VTDInvDesc {
|
||
|
|
typedef union VTDInvDesc VTDInvDesc;
|
||
|
|
|
||
|
|
/* Masks for struct VTDInvDesc */
|
||
|
|
-#define VTD_INV_DESC_TYPE 0xf
|
||
|
|
+#define VTD_INV_DESC_TYPE(val) ((((val) >> 5) & 0x70ULL) | \
|
||
|
|
+ ((val) & 0xfULL))
|
||
|
|
#define VTD_INV_DESC_CC 0x1 /* Context-cache Invalidate Desc */
|
||
|
|
#define VTD_INV_DESC_IOTLB 0x2
|
||
|
|
#define VTD_INV_DESC_DEVICE 0x3
|
||
|
|
@@ -356,7 +357,7 @@ typedef union VTDInvDesc VTDInvDesc;
|
||
|
|
#define VTD_INV_DESC_WAIT_IF (1ULL << 4)
|
||
|
|
#define VTD_INV_DESC_WAIT_FN (1ULL << 6)
|
||
|
|
#define VTD_INV_DESC_WAIT_DATA_SHIFT 32
|
||
|
|
-#define VTD_INV_DESC_WAIT_RSVD_LO 0Xffffff80ULL
|
||
|
|
+#define VTD_INV_DESC_WAIT_RSVD_LO 0Xfffff180ULL
|
||
|
|
#define VTD_INV_DESC_WAIT_RSVD_HI 3ULL
|
||
|
|
|
||
|
|
/* Masks for Context-cache Invalidation Descriptor */
|
||
|
|
@@ -367,7 +368,7 @@ typedef union VTDInvDesc VTDInvDesc;
|
||
|
|
#define VTD_INV_DESC_CC_DID(val) (((val) >> 16) & VTD_DOMAIN_ID_MASK)
|
||
|
|
#define VTD_INV_DESC_CC_SID(val) (((val) >> 32) & 0xffffUL)
|
||
|
|
#define VTD_INV_DESC_CC_FM(val) (((val) >> 48) & 3UL)
|
||
|
|
-#define VTD_INV_DESC_CC_RSVD 0xfffc00000000ffc0ULL
|
||
|
|
+#define VTD_INV_DESC_CC_RSVD 0xfffc00000000f1c0ULL
|
||
|
|
|
||
|
|
/* Masks for IOTLB Invalidate Descriptor */
|
||
|
|
#define VTD_INV_DESC_IOTLB_G (3ULL << 4)
|
||
|
|
@@ -377,7 +378,7 @@ typedef union VTDInvDesc VTDInvDesc;
|
||
|
|
#define VTD_INV_DESC_IOTLB_DID(val) (((val) >> 16) & VTD_DOMAIN_ID_MASK)
|
||
|
|
#define VTD_INV_DESC_IOTLB_ADDR(val) ((val) & ~0xfffULL)
|
||
|
|
#define VTD_INV_DESC_IOTLB_AM(val) ((val) & 0x3fULL)
|
||
|
|
-#define VTD_INV_DESC_IOTLB_RSVD_LO 0xffffffff0000ff00ULL
|
||
|
|
+#define VTD_INV_DESC_IOTLB_RSVD_LO 0xffffffff0000f100ULL
|
||
|
|
#define VTD_INV_DESC_IOTLB_RSVD_HI 0xf80ULL
|
||
|
|
|
||
|
|
/* Mask for Device IOTLB Invalidate Descriptor */
|
||
|
|
@@ -385,7 +386,7 @@ typedef union VTDInvDesc VTDInvDesc;
|
||
|
|
#define VTD_INV_DESC_DEVICE_IOTLB_SIZE(val) ((val) & 0x1)
|
||
|
|
#define VTD_INV_DESC_DEVICE_IOTLB_SID(val) (((val) >> 32) & 0xFFFFULL)
|
||
|
|
#define VTD_INV_DESC_DEVICE_IOTLB_RSVD_HI 0xffeULL
|
||
|
|
-#define VTD_INV_DESC_DEVICE_IOTLB_RSVD_LO 0xffff0000ffe0fff8
|
||
|
|
+#define VTD_INV_DESC_DEVICE_IOTLB_RSVD_LO 0xffff0000ffe0f1f0
|
||
|
|
|
||
|
|
/* Rsvd field masks for spte */
|
||
|
|
#define VTD_SPTE_SNP 0x800ULL
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|