From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87E92CA5FA1 for ; Tue, 29 Sep 2026 07:21:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=aRnDa4vAhhdrCZggWPWQopoSXxq018MvNv/VSTy8Lhs=; b=efI9plofKA+TvjhJGQksFZHwXs 9XEfyI6qc/BejxL6rnm7mVtFlX5vyL/yEypLEUPs1EiqbtWh4jBxaj86EJ+xqHl5TKWntxxAbAHOY RR9mTiDEat7MQrn4152iup08ptX6uzMuJ9bPayDpnrdTdjGXfZlaranmz/uqWvdhK1Q59C8L5Mwzm gyTVnNbQgNfJ5wY13cm4zVBim/nTKIM7cgFK0KIryoZ/1G+Jnl83XKTN20uv9Ne0QTJ3NsrBAXsVd G6AK9EzP8E3eoaZhLQUcK/ipPFIIHRlFgeXVerXW4iGbRIzo9MZdmA3OCaSbDyEbRDptAH9U++tm2 5hkjcr1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1xBS92-00000002ayW-04iS; Tue, 29 Sep 2026 07:20:56 +0000 Received: from mail-pf1-x446.google.com ([2607:f8b0:4864:20::446]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1xBS8J-00000002aPA-3mID for linux-arm-kernel@lists.infradead.org; Tue, 29 Sep 2026 07:20:13 +0000 Received: by mail-pf1-x446.google.com with SMTP id d2e1a72fcca58-88085ea083fso1839577b3a.0 for ; Tue, 29 Sep 2026 00:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1790666410; x=1791271210; darn=lists.infradead.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=aRnDa4vAhhdrCZggWPWQopoSXxq018MvNv/VSTy8Lhs=; b=HYzmlfZfGmPUDk/VXAYpCAfagC7geiG/EbkA2SHJelXjl0i26D6QKA5hmyqnTSrZVJ FIfdUW9nhTaCFHhuPm4QL/6ZsV/Vj6Ja6YML5k8HaYS0GcHGz3odV/pslGFfW4Bu846C eZXfR/0z/+EfzIsZB7DyR40kq1pNsyKsGG8gcv7u0wvNh8Sc8GNvoXtWn2eN7eSzXexZ cqixhOhj2HHYwLWQF0b/XjlrE3a5kIG2cvnHkbIPKTC8bCjaOGZsPBZwEgRhapz4S4X3 mLliC6fs393ihSZFZla4h7VqLJMq/IfXocMGNp+gkZCnQgMCAvyt4UsDq/S7s0IB6r6Z KF2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790666410; x=1791271210; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=aRnDa4vAhhdrCZggWPWQopoSXxq018MvNv/VSTy8Lhs=; b=0u1efcbfCfNT5hkALRZ3xQYcEQjP/bvwGP3nD48azwpBeZJcJ9KpxZ+v9dB3ocZ+7X ZlkxgpUYALLLJMXjAtRshoTuqCmriLUv91RXgvlmhGw3MjN/R+3ejJBFKBpJauKQTyRR +spArzNPBe1kzn42cJCtaKAKb7k54so9Qjc8ZiYy8pABPC31YAfqPg28KxBNN/MpUgrN DfZfO4/9fxnrkRbK9uitnusxG2m6HwGqmcTXnb+acgFfPiyBVWvEhCUzDXapEzljhTNa briNHWl10O4H3AAxA8EHLtvrSekkKD0LnAAstBZRD+cTJx4nSvpHuTGwDD2BNVfKM+Mb OXYA== X-Forwarded-Encrypted: i=1; AKwUvBxetr1sWkbC7Iv9u7fbUqwfOQVDu+VGUdiZg2SA1pOMl4PlkcY9+IrpS+4auAeKoKF7DRiKKX38a4R208y155lK@lists.infradead.org X-Gm-Message-State: AFuF++nDpQfJr+URzzL9eZ7rJ44K1sW08e1IRhUt0NeJCsOt24bN1B8L rSbmtLFrC6xn03d5BE1p1xIuf/Xl1lptTjbYSDcTOn2QFWLCWk144S2BNuqCBiyaFTZgxHPjw59 /MQ== X-Received: from pfbhu13.prod.google.com ([2002:a05:6a00:698d:b0:884:7cdd:23d1]) (user=praan job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:94fb:b0:882:1d:c2ba with SMTP id d2e1a72fcca58-882001dcd3cmr5592982b3a.22.1790666410148; Tue, 29 Sep 2026 00:20:10 -0700 (PDT) Date: Tue, 29 Sep 2026 07:19:48 +0000 In-Reply-To: <20260929071950.2710070-1-praan@google.com> Mime-Version: 1.0 References: <20260929071950.2710070-1-praan@google.com> X-Mailer: git-send-email 2.56.0.rc1.315.gc6ed9934b7-goog Message-ID: <20260929071950.2710070-8-praan@google.com> Subject: [RFC PATCH v1 7/9] iommu/arm-smmu-v3: Retain SMMUEN across a Live Update restore From: Pranjal Shrivastava To: iommu@lists.linux.dev, Will Deacon , Jason Gunthorpe Cc: Robin Murphy , Joerg Roedel , Nicolin Chen , Kevin Tian , Samiullah Khawaja , David Matlack , Vipin Sharma , Mostafa Saleh , Daniel Mentz , Pasha Tatashin , Pratyush Yadav , linux-arm-kernel@lists.infradead.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Pranjal Shrivastava Content-Type: text/plain; charset="UTF-8" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260929_002011_953209_D6D8F37B X-CRM114-Status: GOOD ( 17.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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