[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1568137765-20278-6-git-send-email-sironi@amazon.de>
Date: Tue, 10 Sep 2019 19:49:25 +0200
From: Filippo Sironi <sironi@...zon.de>
To: sironi@...zon.de, joro@...tes.org,
iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org
Cc: Wei Wang <wawei@...zon.de>
Subject: [PATCH 5/5] iommu/amd: Hold the domain lock when calling domain_flush_tlb[_pde]
From: Wei Wang <wawei@...zon.de>
domain_flush_tlb[_pde] traverses the device list, which is protected by
the domain lock.
Signed-off-by: Wei Wang <wawei@...zon.de>
Signed-off-by: Filippo Sironi <sironi@...zon.de>
---
drivers/iommu/amd_iommu.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 3714ae5ded31..f5df23acd1c7 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1806,7 +1806,11 @@ static void free_gcr3_table(struct protection_domain *domain)
static void dma_ops_domain_flush_tlb(struct dma_ops_domain *dom)
{
+ unsigned long flags;
+
+ spin_lock_irqsave(&dom->domain.lock, flags);
domain_flush_tlb(&dom->domain);
+ spin_unlock_irqrestore(&dom->domain.lock, flags);
domain_flush_complete(&dom->domain);
}
@@ -2167,7 +2171,9 @@ static int attach_device(struct device *dev,
* left the caches in the IOMMU dirty. So we have to flush
* here to evict all dirty stuff.
*/
+ spin_lock_irqsave(&domain->lock, flags);
domain_flush_tlb_pde(domain);
+ spin_unlock_irqrestore(&domain->lock, flags);
domain_flush_complete(domain);
@@ -3245,8 +3251,11 @@ static bool amd_iommu_is_attach_deferred(struct iommu_domain *domain,
static void amd_iommu_flush_iotlb_all(struct iommu_domain *domain)
{
struct protection_domain *dom = to_pdomain(domain);
+ unsigned long flags;
+ spin_lock_irqsave(&dom->lock, flags);
domain_flush_tlb_pde(dom);
+ spin_unlock_irqrestore(&dom->lock, flags);
domain_flush_complete(dom);
}
--
2.7.4
Powered by blists - more mailing lists