From: Timur Tabi <timur-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>,
Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>,
Joerg Roedel <joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>,
nwatters-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
Sameer Goel <sgoel-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
Cc: timur-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org
Subject: [PATCH] iommu/arm-smmu-v3: Set GBPA to abort all transactions
Date: Wed, 28 Mar 2018 09:39:40 -0500 [thread overview]
Message-ID: <1522247980-31892-1-git-send-email-timur@codeaurora.org> (raw)
From: Sameer Goel <sgoel-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.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-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.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.
WARNING: multiple messages have this Message-ID (diff)
From: timur@codeaurora.org (Timur Tabi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] iommu/arm-smmu-v3: Set GBPA to abort all transactions
Date: Wed, 28 Mar 2018 09:39:40 -0500 [thread overview]
Message-ID: <1522247980-31892-1-git-send-email-timur@codeaurora.org> (raw)
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.
next reply other threads:[~2018-03-28 14:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-28 14:39 Timur Tabi [this message]
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-03-28 15:00 ` Marc Zyngier
2018-04-11 15:58 ` Goel, Sameer
2018-04-11 15:58 ` Goel, Sameer
[not found] ` <3772fb2d-01b7-4820-6d13-a0263654dabc-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-04-11 16:54 ` Marc Zyngier
2018-04-11 16:54 ` Marc Zyngier
[not found] ` <438a6180-fca8-d3a1-985f-e595529911f3-5wv7dgnIgG8@public.gmane.org>
2018-04-12 10:17 ` Robin Murphy
2018-04-12 10:17 ` Robin Murphy
[not found] ` <7756f245-6c63-92d4-d101-4040a45b660b-5wv7dgnIgG8@public.gmane.org>
2018-04-12 10:55 ` Will Deacon
2018-04-12 10:55 ` Will Deacon
2018-04-12 11:56 ` Marc Zyngier
2018-04-12 11:56 ` Marc Zyngier
[not found] ` <265a41d4-ec3c-6697-0340-6830807ea10f-5wv7dgnIgG8@public.gmane.org>
2018-05-11 16:15 ` Goel, Sameer
2018-05-11 16:15 ` Goel, Sameer
2018-05-11 20:52 ` Nate Watterson
2018-05-11 20:52 ` Nate Watterson
[not found] ` <1522247980-31892-1-git-send-email-timur-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-04-05 11:26 ` Will Deacon
2018-04-05 11:26 ` Will Deacon
2018-04-11 15:54 ` Goel, Sameer
2018-04-11 15:54 ` Goel, Sameer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1522247980-31892-1-git-send-email-timur@codeaurora.org \
--to=timur-sgv2jx0feol9jmxxk+q4oq@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=nwatters-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=robin.murphy-5wv7dgnIgG8@public.gmane.org \
--cc=sgoel-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=will.deacon-5wv7dgnIgG8@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.