From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 817CD32B130 for ; Fri, 17 Jul 2026 21:43:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784324615; cv=none; b=i5PxrU9+BL4AsPuP6+h5dwZpGBRWbKVixtfqQ84DFMFzKuzpG4JZxiF1AuDVxTGDuQKLmUv5VBoDZchLla829neMFuEFT08ibA0Rcawz/bJ5yH1lQzfpv6AQ73rGkiUod7nJTXELOhnI/l7cAtf+TBqXWzM9wNhH1WIMGWyojbA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784324615; c=relaxed/simple; bh=hnpcUpkk///hUDHKjCL3LkQz9YwT/XI/fDVujSOOcRE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SoHgG/mOgD24eGoHI2vOPXnN/23+E9LPNb741rUVW/WhUj/nBaW5FihpyG7UdwN+qcKb5JKwewvvgMx2CZgah/cF4RUaOScQtcPpyyzvKc6gL0iuyk9wrEM5iEUfG+e9KFVqQ6i+26eGeKbbz+3OuERDWxmBc+cTswnPoHttyT4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ri5z1u79; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ri5z1u79" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2ccdf36f63dso224615ad.0 for ; Fri, 17 Jul 2026 14:43:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784324612; x=1784929412; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=IOoEkiQgKR8GN4dBbuTr1zjhYxhyxaeDiS2y4HIEAzc=; b=ri5z1u79CsNTtXi6vWVCZLV1Yzd2Mm93GgX6jeW9UpDxIV0qcCRPEy4EOQGzsKPJPA 5ausnvbpfYLUh0NmYK6q6u8XgjbAvvqlhwvTkCfRs3ryv9LMLUqAtuBbTqHJByzfi1iB c3i6V5NfYavLVBnet5hM/vTaBj5iqCP+LlWpY6BczgogD1/TOnMEaSs0bCKkzaapg/eD Xp2HIz4zLZYCNhwVbLPGY1Y2Rm9e2j+4/MzZv/ZfZVjMeiuBUd7Of1RuN8YVI+4pm8JW LYcOX4u5blf9OLmvQIPv/nQJlksHZSvqR2YagpO50wJSqSFK+tpQ12ZiPkYFxhujf52+ JzJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784324612; x=1784929412; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=IOoEkiQgKR8GN4dBbuTr1zjhYxhyxaeDiS2y4HIEAzc=; b=Scv3deYSQwtoZkUAqS8FQZwoaWcG4Oea2fN/skU2GVSUm7/Up6Kflc9vDDxX7mbeRb CvPZ4FoH5/IfgmgWr3OWVGNFly1VvCIBTZmwZQFSOVx5rE61nDdDrKo9EdF5lw5BBpDk 8sBP5s5iQekKT6fVhzmE25KUOk1qzAgsyy1/LiWj4mHdtnrJhuy+tprsapdWOZAlXiWn ouDfr+VzSWTPlJuS0843HhopN0drlNbk3xUqz2PR7mocHOkipleOWVOKXoUV1hcSWDtR MJa7yDWLSm1fyYqUkd3cEc8gWzp+HCCZR9Wm1QBkVHDHuWUsyrPalJmnXdCs5f60TFwF +k8A== X-Forwarded-Encrypted: i=1; AHgh+RomokXJ6osSZtO0FyOoT+j+L1oB6ynAhH/cwoNPU5NDMkENuDqjr0b4Dz5y1UCt6Ura7qmiLTVIIKUnKw8=@vger.kernel.org X-Gm-Message-State: AOJu0YxvpFRvNvmj0aiPe4obAJYlRybhrWhKYjaINbAHk+QYJ67pUkqd r/FRCLoQ0MEfGtZnfB3oxf3sur0dpUOfK2nCsnQHTwM7NenBpiyGEkltKok6bj7wqA== X-Gm-Gg: AfdE7cn1gooJlD9SAE6pmwlm1WWdMsVpfTtGaV3BA/bU0a/fqcTybv184ZT6xKYTq54 XoasNfHcm+zK1CP6jqDPdP1snXsTZPLP6gEdLXWKtX+WuMMCgNBg/lDoCTl2CN99n74OrQljz8t JTSR050YXRDWaKK5sJ2sCk0KgSxcqsoGh4us8CS/yemCpxVZgX8Zg6BqDCeprmpUN+vNjg1JqDK Y76Y7rvgznog1uS+4TvOdvcC0IwGOXzTrAH3l3IJ3G8d6IWXKzmEb3pr6EbMr9zQhUiWAwt5mlR mNg7JX70YnwSU88Sxv+2bweRjV6GTF/nknwQxTSIx4EODsvy6hdG1/wNE/2PQPjjTmEHUSxGmfL OlcZF8lpd6lKEYKwtYMpsGQ+aonLNooEg9yY7xZJ2uKTyf/1T4ma09Rs5853k5os1xq3Bn7B0Ux D33jGyROZc+yZEhv1xPAc3wj9fReq0iaWBjfs7PHFfG8dC6bw= X-Received: by 2002:a17:902:da85:b0:2cc:9473:97a1 with SMTP id d9443c01a7336-2cf45aa8fc1mr1052835ad.22.1784324611243; Fri, 17 Jul 2026 14:43:31 -0700 (PDT) Received: from google.com (10.129.124.34.bc.googleusercontent.com. [34.124.129.10]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3142a20b1f3sm10613093eec.26.2026.07.17.14.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 14:43:30 -0700 (PDT) Date: Fri, 17 Jul 2026 21:43:24 +0000 From: Pranjal Shrivastava To: Nicolin Chen Cc: will@kernel.org, robin.murphy@arm.com, jgg@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, smostafa@google.com, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, jamien@nvidia.com Subject: Re: [PATCH v8 0/9] iommu/arm-smmu-v3: Adopt the crashed kernel's stream table for kdump Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Jul 10, 2026 at 05:52:41PM -0700, Nicolin Chen wrote: Hi Nicolin, > When transitioning to a kdump kernel, the primary kernel might have crashed > while endpoint devices were actively bus-mastering DMA. Currently, the SMMU > driver aggressively resets the hardware during probe by clearing CR0_SMMUEN > and setting the Global Bypass Attribute (GBPA) to ABORT. > > In a kdump scenario, this aggressive reset is highly destructive: > a) If GBPA is set to ABORT, in-flight DMA will be aborted, generating fatal > PCIe AER or SErrors that may panic the kdump kernel > b) If GBPA is set to BYPASS, in-flight DMA targeting some IOVAs will bypass > the SMMU and corrupt the physical memory at those 1:1 mapped IOVAs. > > To safely absorb in-flight DMA, the kdump kernel must leave SMMUEN=1 intact > and avoid modifying STRTAB_BASE. This allows HW to continue translating in- > flight DMA using the crashed kernel's page tables until the endpoint device > drivers probe and quiesce their respective hardware. > > However, the ARM SMMUv3 architecture specification states that updating the > SMMU_STRTAB_BASE register while SMMUEN == 1 is UNPREDICTABLE or ignored. > > This leaves a kdump kernel no choice but to adopt the stream table from the > crashed kernel. > > In this series: > - Introduce an ARM_SMMU_OPT_KDUMP_ADOPT > - Skip SMMUEN and STRTAB_BASE resets in arm_smmu_device_reset() > - Skip EVENTQ/PRIQ setup including interrupts and their handlers > - Memremap the crashed kernel's stream tables into the kdump kernel [*] > - Reserve the crashed kernel's in-use ASIDs and VMIDs, preventing any TLB > aliasing with the kdump kernel's own domains > - Defer any default domain attachment to retain STEs until device drivers > explicitly request it. > Most of the kdump code is added to a new arm-smmu-v3-kdump.c that is only > built when CONFIG_CRASH_DUMP is enabled. > > [*] For verification reasons, this series only fixes coherent SMMUs. > > For non-ARM_SMMU_OPT_KDUMP_ADOPT cases, keep a status quo since the commit > 3f54c447df34f ("iommu/arm-smmu-v3: Don't disable SMMU in kdump kernel"): > full reset followed by driver-initiated reattach, potentially rejecting any > in-flight DMA. > > Note that this series is no longer treated as a bug fix, since it has grown > fairly big and most of the kdump code now resides in a separate file. For > folks interested in back-porting the change: a v6.12+ kernel (since commit > 85196f54743d ("iommu/arm-smmu-v3: Reorganize struct arm_smmu_strtab_cfg")) > would be still compatible with this series. > [...] > > Nicolin Chen (9): > iommu/arm-smmu-v3: Do not enable EVTQ/PRIQ interrupts in kdump kernel > iommu/arm-smmu-v3: Skip EVTQ/PRIQ setup in kdump kernel > iommu/arm-smmu-v3: Add ARM_SMMU_OPT_KDUMP_ADOPT for kdump kernel > iommu/arm-smmu-v3: Destroy vmid_map ida via devres > iommu/arm-smmu-v3-kdump: Reserve crashed kernel's ASIDs and VMIDs > iommu/arm-smmu-v3-kdump: Implement is_attach_deferred() > iommu/arm-smmu-v3: Retain CR0_SMMUEN during kdump device reset > iommu/arm-smmu-v3: Skip RMR bypass for kdump adoption > iommu/arm-smmu-v3: Detect ARM_SMMU_OPT_KDUMP_ADOPT in probe() > > drivers/iommu/arm/arm-smmu-v3/Makefile | 1 + > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 48 ++ > .../iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c | 579 ++++++++++++++++++ > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 246 ++++++-- > 4 files changed, 806 insertions(+), 68 deletions(-) > create mode 100644 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c This series seems to align with the restore part of my SMMUv3 Live Update (Kexec Handover) support. I have a WIP series in dev on github: https://github.com/pran005/linux/tree/wip-arm-smmu-lu While going through the Stream Table adoption code in this series, I realized there is significant overlap between how kdump adopts a crashed kernel's SMMU structures and how we restore preserved SMMU state via Kexec HandOver (KHO) during a live update For e.g., the KHO preservation hook in my series explicitly tracks and serializes the physical addresses of all active L1/L2 tables into the KHO Device Tree so the incoming kernel can kho_restore them. However, looking at your approach, I think I can slightly rework my preservation logic and instead of bloating the KHO ABI with physical addresses, I could re-use your exact table-walking logic during probe to parse the live L1/L2 structures directly from registers, identify the valid tables, and kho/dma_restore them. There could me small differences though, for example instead of memremap stuff, we'd have to use the kho/dma_restore API (which can be done by passing some op like the data structure writers we have?) Similarly, maybe reserving ASID/VMID can be potentially re-used as well.. Since, I plan to introduce another file: arm-smmu-v3-liveupdate.c and given how much of this adoption and restoration logic is re-usable (parsing STRTAB_BASE, walking the L1 array, restoring L2s (not deferred for KHO), I wanted to start a discussion to see if it makes sense to factor this common code out into an arm-smmu-v3-kexec.c (or similar)? I'm not trying to delay this series by any chance and I would be more than happy to rebase my Live Update series on top of this series and refactor to share this core logic between the 2 new files: arm-smmu-v3-kdump.c & arm-smmu-v3-liveupdate.c I just wanted to start and early discussion since there's some overlap and align on a way forward. Thanks, Praan