Skip to content

Commit a4544c4

Browse files
yiliu1765mstsirkin
authored andcommitted
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 <[email protected]> Message-Id: <[email protected]> Reviewed-by: Peter Xu <[email protected]> Acked-by: Jason Wang <[email protected]> Cc: [email protected] Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 9b3a35e commit a4544c4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

hw/i386/intel_iommu.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2549,6 +2549,11 @@ static bool vtd_process_inv_desc(IntelIOMMUState *s)
25492549
/* Try to fetch and process more Invalidation Descriptors */
25502550
static void vtd_fetch_inv_desc(IntelIOMMUState *s)
25512551
{
2552+
int qi_shift;
2553+
2554+
/* Refer to 10.4.23 of VT-d spec 3.0 */
2555+
qi_shift = s->iq_dw ? VTD_IQH_QH_SHIFT_5 : VTD_IQH_QH_SHIFT_4;
2556+
25522557
trace_vtd_inv_qi_fetch();
25532558

25542559
if (s->iq_tail >= s->iq_size) {
@@ -2567,7 +2572,7 @@ static void vtd_fetch_inv_desc(IntelIOMMUState *s)
25672572
}
25682573
/* Must update the IQH_REG in time */
25692574
vtd_set_quad_raw(s, DMAR_IQH_REG,
2570-
(((uint64_t)(s->iq_head)) << VTD_IQH_QH_SHIFT) &
2575+
(((uint64_t)(s->iq_head)) << qi_shift) &
25712576
VTD_IQH_QH_MASK);
25722577
}
25732578
}

hw/i386/intel_iommu_internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@
230230
#define VTD_IQA_DW_MASK 0x800
231231

232232
/* IQH_REG */
233-
#define VTD_IQH_QH_SHIFT 4
233+
#define VTD_IQH_QH_SHIFT_4 4
234+
#define VTD_IQH_QH_SHIFT_5 5
234235
#define VTD_IQH_QH_MASK 0x7fff0ULL
235236

236237
/* ICS_REG */

0 commit comments

Comments
 (0)