mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pranjal Shrivastava <praan@google.com>
To: iommu@lists.linux.dev, Will Deacon <will@kernel.org>,
	 Jason Gunthorpe <jgg@nvidia.com>
Cc: Robin Murphy <robin.murphy@arm.com>,
	Joerg Roedel <joro@8bytes.org>,
	 Nicolin Chen <nicolinc@nvidia.com>,
	Kevin Tian <kevin.tian@intel.com>,
	 Samiullah Khawaja <skhawaja@google.com>,
	David Matlack <dmatlack@google.com>,
	 Vipin Sharma <vipinsh@google.com>,
	Mostafa Saleh <smostafa@google.com>,
	 Daniel Mentz <danielmentz@google.com>,
	Pasha Tatashin <pasha.tatashin@soleen.com>,
	 Pratyush Yadav <pratyush@kernel.org>,
	linux-arm-kernel@lists.infradead.org,  kexec@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	 Pranjal Shrivastava <praan@google.com>
Subject: [RFC PATCH v1 7/9] iommu/arm-smmu-v3: Retain SMMUEN across a Live Update restore
Date: Tue, 29 Sep 2026 07:19:48 +0000	[thread overview]
Message-ID: <20260929071950.2710070-8-praan@google.com> (raw)
In-Reply-To: <20260929071950.2710070-1-praan@google.com>

arm_smmu_device_reset() clears SMMUEN and rewrites CR1, CR2 and
STRTAB_BASE, aborting the DMA of the preserved devices. The kdump adoption
path already avoids this for a live Stream Table.

Introduce arm_smmu_strtab_is_live() and route a Live Update restore
through the kdump reset path. Also ack a stale GERROR, since the outgoing
kernel masked the interrupts, and skip installing the RMR bypass STEs.

Signed-off-by: Pranjal Shrivastava <praan@google.com>
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 29 ++++++++++++++-------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index 3cf97f451b64..54c97ebc15b2 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -5048,6 +5048,13 @@ static void arm_smmu_write_strtab(struct arm_smmu_device *smmu)
 	writel_relaxed(reg, smmu->base + ARM_SMMU_STRTAB_BASE_CFG);
 }
 
+/* Adopted by kdump or restored by LU (a failed restore fails the probe) */
+static bool arm_smmu_strtab_is_live(struct arm_smmu_device *smmu)
+{
+	return (smmu->options & ARM_SMMU_OPT_KDUMP_ADOPT) ||
+	       iommu_get_preserved_data(smmu->base_phys, IOMMU_ARM_SMMUV3);
+}
+
 static int arm_smmu_device_reset(struct arm_smmu_device *smmu)
 {
 	int ret;
@@ -5064,10 +5071,11 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu)
 	 * According to spec, updating STRTAB_BASE/CR1/CR2 when CR0_SMMUEN=1 is
 	 * CONSTRAINED UNPREDICTABLE. So, skip those register updates and rely
 	 * on the adopted stream table from the crashed kernel.
+	 * Same for a Live Update restore.
 	 */
-	if (smmu->options & ARM_SMMU_OPT_KDUMP_ADOPT) {
-		dev_info(smmu->dev,
-			 "kdump: retaining SMMUEN for in-flight DMA\n");
+	if (arm_smmu_strtab_is_live(smmu)) {
+		dev_info(smmu->dev, "%s: retaining SMMUEN for in-flight DMA\n",
+			 is_kdump_kernel() ? "kdump" : "live update");
 		enables = reg & ~(CR0_CMDQEN | CR0_EVTQEN | CR0_PRIQEN);
 		goto reset_queues;
 	}
@@ -5103,7 +5111,7 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu)
 	arm_smmu_write_strtab(smmu);
 
 reset_queues:
-	if (smmu->options & ARM_SMMU_OPT_KDUMP_ADOPT) {
+	if (arm_smmu_strtab_is_live(smmu)) {
 		/*
 		 * Disable queues since arm_smmu_device_disable() was skipped.
 		 * CR0 fields are independent per spec, so the queue enable bits
@@ -5122,8 +5130,9 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu)
 	 * errors would be visible. Ack everything prior to re-enabling the CMDQ
 	 * as a stale CMDQ_ERR would halt the CMDQ and new command will timeout.
 	 * Acking SFM_ERR is defined too, although it would not exit the SFM.
+	 * Same for a Live Update, as the outgoing kernel masked the interrupts.
 	 */
-	if (is_kdump_kernel()) {
+	if (is_kdump_kernel() || arm_smmu_strtab_is_live(smmu)) {
 		u32 gerror = readl_relaxed(smmu->base + ARM_SMMU_GERROR);
 		u32 gerrorn = readl_relaxed(smmu->base + ARM_SMMU_GERRORN);
 
@@ -5193,10 +5202,10 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu)
 	}
 
 	/*
-	 * In a kdump adopt case, retain the crashed kernel's ATS-check policy
-	 * captured above rather than forcing it on.
+	 * In a kdump adopt or a Live Update restore case, retain the previous
+	 * kernel's ATS-check policy captured above rather than forcing it on.
 	 */
-	if (!(smmu->options & ARM_SMMU_OPT_KDUMP_ADOPT) &&
+	if (!arm_smmu_strtab_is_live(smmu) &&
 	    (smmu->features & ARM_SMMU_FEAT_ATS)) {
 		enables |= CR0_ATSCHK;
 		ret = arm_smmu_write_reg_sync(smmu, enables, ARM_SMMU_CR0,
@@ -5722,8 +5731,10 @@ static void arm_smmu_rmr_install_bypass_ste(struct arm_smmu_device *smmu)
 	 * Kdump adoption keeps the crashed kernel's table live. Rewriting the
 	 * adopted STE here could expose an in-flight fetch to a transient V=0
 	 * entry, or change Cfg=translate to Cfg=bypass. Must skip here.
+	 * Same for a Live Update restore.
+	 * TODO: Re-install the bypass STEs of the unpreserved RMR SIDs.
 	 */
-	if (smmu->options & ARM_SMMU_OPT_KDUMP_ADOPT)
+	if (arm_smmu_strtab_is_live(smmu))
 		return;
 
 	INIT_LIST_HEAD(&rmr_list);
-- 
2.56.0.rc1.315.gc6ed9934b7-goog


  parent reply	other threads:[~2026-09-29  7:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29  7:19 [RFC PATCH v1 0/9] iommu/arm-smmu-v3: Implement Live Update support Pranjal Shrivastava
2026-09-29  7:19 ` [RFC PATCH v1 1/9] iommu/kho: Extend IOMMU KHO ABI for ARM SMMUv3 Pranjal Shrivastava
2026-09-29  7:19 ` [RFC PATCH v1 2/9] iommu/arm-smmu-v3: Implement KHO preservation for STEs Pranjal Shrivastava
2026-09-29  7:19 ` [RFC PATCH v1 3/9] iommu/arm-smmu-v3: Implement CD Table preservation Pranjal Shrivastava
2026-09-29  7:19 ` [RFC PATCH v1 4/9] iommu/arm-smmu-v3: Implement Live Update Stream Table restoration Pranjal Shrivastava
2026-09-29  7:19 ` [RFC PATCH v1 5/9] iommu/arm-smmu-v3: Implement Live Update CD " Pranjal Shrivastava
2026-09-29  7:19 ` [RFC PATCH v1 6/9] iommu/arm-smmu-v3: Implement Live Update shutdown Pranjal Shrivastava
2026-09-29  7:19 ` Pranjal Shrivastava [this message]
2026-09-29  7:19 ` [RFC PATCH v1 8/9] iommu/arm-smmu-v3: Inherit the ASID/VMID of restored domains Pranjal Shrivastava
2026-09-29  7:19 ` [RFC PATCH v1 9/9] iommu/arm-smmu-v3: Adopt the Event queue across a Live Update Pranjal Shrivastava

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=20260929071950.2710070-8-praan@google.com \
    --to=praan@google.com \
    --cc=danielmentz@google.com \
    --cc=dmatlack@google.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolinc@nvidia.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=pratyush@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=skhawaja@google.com \
    --cc=smostafa@google.com \
    --cc=vipinsh@google.com \
    --cc=will@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®