From: Quan Xu Date: Mon, 14 Mar 2016 11:59:39 +0000 (+0100) Subject: AMD IOMMU: fix an init time spinlock flaw X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~1558 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=bf55ead25c5e9a7fbd8fa47c64ec8d1557478efb;p=xen.git AMD IOMMU: fix an init time spinlock flaw pcidevs_lock doesn't require interrupts to be disabled while being acquired. However there remains an exception in AMD IOMMU code, where the lock is acquired with interrupt disabled. This inconsistency might lead to deadlock. The fix is straightforward to use spin_lock instead. Also interrupt has been enabled when this function is invoked, so we're sure consistency around pcidevs_lock can be guaranteed after this fix. Signed-off-by: Quan Xu Reviewed-by: Dario Faggioli Reviewed-by: Kevin Tian Acked-by: Jan Beulich --- diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthrough/amd/iommu_init.c index d90a2d22cb..a40049749a 100644 --- a/xen/drivers/passthrough/amd/iommu_init.c +++ b/xen/drivers/passthrough/amd/iommu_init.c @@ -778,7 +778,6 @@ static bool_t __init set_iommu_interrupt_handler(struct amd_iommu *iommu) { int irq, ret; hw_irq_controller *handler; - unsigned long flags; u16 control; irq = create_irq(NUMA_NO_NODE); @@ -788,10 +787,10 @@ static bool_t __init set_iommu_interrupt_handler(struct amd_iommu *iommu) return 0; } - spin_lock_irqsave(&pcidevs_lock, flags); + spin_lock(&pcidevs_lock); iommu->msi.dev = pci_get_pdev(iommu->seg, PCI_BUS(iommu->bdf), PCI_DEVFN2(iommu->bdf)); - spin_unlock_irqrestore(&pcidevs_lock, flags); + spin_unlock(&pcidevs_lock); if ( !iommu->msi.dev ) { AMD_IOMMU_DEBUG("IOMMU: no pdev for %04x:%02x:%02x.%u\n",