Skip to content

Commit 6e4e9ec

Browse files
LuBaolujoergroedel
authored andcommitted
iommu/vt-d: Serialize IOMMU GCMD register modifications
The VT-d spec requires (10.4.4 Global Command Register, GCMD_REG General Description) that: If multiple control fields in this register need to be modified, software must serialize the modifications through multiple writes to this register. However, in irq_remapping.c, modifications of IRE and CFI are done in one write. We need to do two separate writes with STS checking after each. It also checks the status register before writing command register to avoid unnecessary register write. Fixes: af8d102 ("x86/intel/irq_remapping: Clean up x2apic opt-out security warning mess") Signed-off-by: Lu Baolu <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Jacob Pan <[email protected]> Cc: Kevin Tian <[email protected]> Cc: Ashok Raj <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 365d2a2 commit 6e4e9ec

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/iommu/intel/irq_remapping.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,12 +508,18 @@ static void iommu_enable_irq_remapping(struct intel_iommu *iommu)
508508

509509
/* Enable interrupt-remapping */
510510
iommu->gcmd |= DMA_GCMD_IRE;
511-
iommu->gcmd &= ~DMA_GCMD_CFI; /* Block compatibility-format MSIs */
512511
writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG);
513-
514512
IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG,
515513
readl, (sts & DMA_GSTS_IRES), sts);
516514

515+
/* Block compatibility-format MSIs */
516+
if (sts & DMA_GSTS_CFIS) {
517+
iommu->gcmd &= ~DMA_GCMD_CFI;
518+
writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG);
519+
IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG,
520+
readl, !(sts & DMA_GSTS_CFIS), sts);
521+
}
522+
517523
/*
518524
* With CFI clear in the Global Command register, we should be
519525
* protected from dangerous (i.e. compatibility) interrupts

0 commit comments

Comments
 (0)