Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: af8d102f999a4 ("x86/intel/irq_remapping: Clean up x2apic opt-out security warning mess")
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: Kevin Tian <kevin.tian@intel.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Link: https://lore.kernel.org/r/20200828000615.8281-1-baolu.lu@linux.intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>

authored by

Lu Baolu and committed by
Joerg Roedel
6e4e9ec6 365d2a23

+8 -2
+8 -2
drivers/iommu/intel/irq_remapping.c
··· 508 508 509 509 /* Enable interrupt-remapping */ 510 510 iommu->gcmd |= DMA_GCMD_IRE; 511 - iommu->gcmd &= ~DMA_GCMD_CFI; /* Block compatibility-format MSIs */ 512 511 writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); 513 - 514 512 IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, 515 513 readl, (sts & DMA_GSTS_IRES), sts); 514 + 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 + } 516 522 517 523 /* 518 524 * With CFI clear in the Global Command register, we should be