[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[qemu-xen staging] intel_iommu: Use correct shift for 256 bits qi descriptor



commit a4544c45e109ceee87ee8c19baff28be3890d788
Author:     Liu Yi L <yi.l.liu@xxxxxxxxx>
AuthorDate: Sat Jul 4 01:07:15 2020 -0700
Commit:     Michael S. Tsirkin <mst@xxxxxxxxxx>
CommitDate: Wed Jul 22 07:57:07 2020 -0400

    intel_iommu: Use correct shift for 256 bits qi descriptor
    
    In chapter 10.4.23 of VT-d spec 3.0, Descriptor Width bit was introduced
    in VTD_IQA_REG. Software could set this bit to tell VT-d the QI descriptor
    from software would be 256 bits. Accordingly, the VTD_IQH_QH_SHIFT should
    be 5 when descriptor size is 256 bits.
    
    This patch adds the DW bit check when deciding the shift used to update
    VTD_IQH_REG.
    
    Signed-off-by: Liu Yi L <yi.l.liu@xxxxxxxxx>
    Message-Id: <1593850035-35483-1-git-send-email-yi.l.liu@xxxxxxxxx>
    Reviewed-by: Peter Xu <peterx@xxxxxxxxxx>
    Acked-by: Jason Wang <jasowang@xxxxxxxxxx>
    Cc: qemu-stable@xxxxxxxxxx
    Reviewed-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
    Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
---
 hw/i386/intel_iommu.c          | 7 ++++++-
 hw/i386/intel_iommu_internal.h | 3 ++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index c56398e991..0c286635cf 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -2549,6 +2549,11 @@ static bool vtd_process_inv_desc(IntelIOMMUState *s)
 /* Try to fetch and process more Invalidation Descriptors */
 static void vtd_fetch_inv_desc(IntelIOMMUState *s)
 {
+    int qi_shift;
+
+    /* Refer to 10.4.23 of VT-d spec 3.0 */
+    qi_shift = s->iq_dw ? VTD_IQH_QH_SHIFT_5 : VTD_IQH_QH_SHIFT_4;
+
     trace_vtd_inv_qi_fetch();
 
     if (s->iq_tail >= s->iq_size) {
@@ -2567,7 +2572,7 @@ static void vtd_fetch_inv_desc(IntelIOMMUState *s)
         }
         /* Must update the IQH_REG in time */
         vtd_set_quad_raw(s, DMAR_IQH_REG,
-                         (((uint64_t)(s->iq_head)) << VTD_IQH_QH_SHIFT) &
+                         (((uint64_t)(s->iq_head)) << qi_shift) &
                          VTD_IQH_QH_MASK);
     }
 }
diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h
index 862033ebe6..3d5487fe2c 100644
--- a/hw/i386/intel_iommu_internal.h
+++ b/hw/i386/intel_iommu_internal.h
@@ -230,7 +230,8 @@
 #define VTD_IQA_DW_MASK             0x800
 
 /* IQH_REG */
-#define VTD_IQH_QH_SHIFT            4
+#define VTD_IQH_QH_SHIFT_4          4
+#define VTD_IQH_QH_SHIFT_5          5
 #define VTD_IQH_QH_MASK             0x7fff0ULL
 
 /* ICS_REG */
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.