mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pranjal Shrivastava <praan@google.com>
To: Nicolin Chen <nicolinc@nvidia.com>
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
Date: Fri, 17 Jul 2026 21:43:24 +0000	[thread overview]
Message-ID: <alqh_NVatGn84o0i@google.com> (raw)
In-Reply-To: <cover.1783729633.git.nicolinc@nvidia.com>

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

      parent reply	other threads:[~2026-07-17 21:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-11  0:52 Nicolin Chen
2026-07-11  0:52 ` [PATCH v8 1/9] iommu/arm-smmu-v3: Do not enable EVTQ/PRIQ interrupts in kdump kernel Nicolin Chen
2026-07-11  0:52 ` [PATCH v8 2/9] iommu/arm-smmu-v3: Skip EVTQ/PRIQ setup " Nicolin Chen
2026-07-11  0:52 ` [PATCH v8 3/9] iommu/arm-smmu-v3: Add ARM_SMMU_OPT_KDUMP_ADOPT for " Nicolin Chen
2026-07-11  0:52 ` [PATCH v8 4/9] iommu/arm-smmu-v3: Destroy vmid_map ida via devres Nicolin Chen
2026-07-11  0:52 ` [PATCH v8 5/9] iommu/arm-smmu-v3-kdump: Reserve crashed kernel's ASIDs and VMIDs Nicolin Chen
2026-07-11  0:52 ` [PATCH v8 6/9] iommu/arm-smmu-v3-kdump: Implement is_attach_deferred() Nicolin Chen
2026-07-11  0:52 ` [PATCH v8 7/9] iommu/arm-smmu-v3: Retain CR0_SMMUEN during kdump device reset Nicolin Chen
2026-07-11  0:52 ` [PATCH v8 8/9] iommu/arm-smmu-v3: Skip RMR bypass for kdump adoption Nicolin Chen
2026-07-11  0:52 ` [PATCH v8 9/9] iommu/arm-smmu-v3: Detect ARM_SMMU_OPT_KDUMP_ADOPT in probe() Nicolin Chen
2026-07-17 21:43 ` Pranjal Shrivastava [this message]

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=alqh_NVatGn84o0i@google.com \
    --to=praan@google.com \
    --cc=iommu@lists.linux.dev \
    --cc=jamien@nvidia.com \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolinc@nvidia.com \
    --cc=robin.murphy@arm.com \
    --cc=smostafa@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