linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/arm-smmu-v3: Set GBPA to abort all transactions
@ 2018-03-28 14:39 Timur Tabi
  2018-03-28 15:00 ` Marc Zyngier
  2018-04-05 11:26 ` Will Deacon
  0 siblings, 2 replies; 11+ messages in thread
From: Timur Tabi @ 2018-03-28 14:39 UTC (permalink / raw)
  To: linux-arm-kernel

From: Sameer Goel <sgoel@codeaurora.org>

Set SMMU_GBPA to abort all incoming translations during the SMMU reset
when SMMUEN==0.

This prevents a race condition where a stray DMA from the crashed primary
kernel can try to access an IOVA address as an invalid PA when SMMU is
disabled during reset in the crash kernel.

Signed-off-by: Sameer Goel <sgoel@codeaurora.org>
---
 drivers/iommu/arm-smmu-v3.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 3f2f1fc68b52..c04a89310c59 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -2458,6 +2458,18 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu, bool bypass)
 	if (reg & CR0_SMMUEN)
 		dev_warn(smmu->dev, "SMMU currently enabled! Resetting...\n");
 
+	/*
+	 * Abort all incoming translations. This can happen in a kdump case
+	 * where SMMU is initialized when a prior DMA is pending. Just
+	 * disabling the SMMU in this case might result in writes to invalid
+	 * PAs.
+	 */
+	ret = arm_smmu_update_gbpa(smmu, 1, GBPA_ABORT);
+	if (ret) {
+		dev_err(smmu->dev, "GBPA not responding to update\n");
+		return ret;
+	}
+
 	ret = arm_smmu_device_disable(smmu);
 	if (ret)
 		return ret;
-- 
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-05-11 20:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-28 14:39 [PATCH] iommu/arm-smmu-v3: Set GBPA to abort all transactions Timur Tabi
2018-03-28 15:00 ` Marc Zyngier
2018-04-11 15:58   ` Goel, Sameer
2018-04-11 16:54     ` Marc Zyngier
2018-04-12 10:17       ` Robin Murphy
2018-04-12 10:55         ` Will Deacon
2018-04-12 11:56         ` Marc Zyngier
2018-05-11 16:15           ` Goel, Sameer
2018-05-11 20:52           ` Nate Watterson
2018-04-05 11:26 ` Will Deacon
2018-04-11 15:54   ` Goel, Sameer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).