* [PATCH v2 0/2] iommu/amd: Fix device table setup in kdump kernels
@ 2026-10-13 12:19 Matt Fleming
2026-10-13 12:19 ` [PATCH v2 1/2] iommu/amd: Program device table when kdump reuse fails Matt Fleming
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Matt Fleming @ 2026-10-13 12:19 UTC (permalink / raw)
To: Joerg Roedel
Cc: Suravee Suthikulpanit, Ashish Kalra, Vasant Hegde,
Sairaj Kodilkar, Ankit Soni, Baoquan He, iommu, linux-kernel,
stable, kernel-team, Matt Fleming
From: Matt Fleming <mfleming@cloudflare.com>
An AMD kdump kernel booted with crashkernel=512M,high and
crashkernel=0,low fails to allocate its device table because there's no
memory below 4G. IOMMU init fails and, on our systems with an Intel
E810 NIC, the ice driver's TX queues time out, so the dump never gets
sent.
Since commit 38e5f33ee359 ("iommu/amd: Reuse device table for kdump"), a
kdump kernel normally reuses the previous kernel's table. Patch 1
programs the new table if reuse fails. Patch 2 drops GFP_DMA32 for
kdump kernels. Normal kernels still allocate below 4G, because that's
what the kdump kernel checks before reusing the table.
On an AMD EPYC system with an E810 NIC, the kdump kernel without these
patches failed the order-9 GFP_DMA32 allocation and its TX queues timed
out. With these patches, the kdump kernel reused the old device table
and the dump was written over the network. The reuse-failure path in
patch 1 was found by code inspection, not exercised by this test.
---
Changes in v2:
- Explain the split base-register write and DMA32 requirement in patch 2.
- Limit patch 2's stable backports to 6.18.x and later, which contain
38e5f33ee359.
- Add Ashish Kalra's and Ankit Soni's Reviewed-by tags to both patches,
and Vasant Hegde's Reviewed-by tag to patch 1.
- No code changes from v1.
v1: https://lore.kernel.org/r/20261002133143.3628181-1-matt@readmodwrite.com
Matt Fleming (2):
iommu/amd: Program device table when kdump reuse fails
iommu/amd: Don't allocate kdump device table from DMA32
drivers/iommu/amd/init.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] iommu/amd: Program device table when kdump reuse fails
2026-10-13 12:19 [PATCH v2 0/2] iommu/amd: Fix device table setup in kdump kernels Matt Fleming
@ 2026-10-13 12:19 ` Matt Fleming
2026-10-13 12:19 ` [PATCH v2 2/2] iommu/amd: Don't allocate kdump device table from DMA32 Matt Fleming
2026-10-14 13:47 ` [PATCH v2 0/2] iommu/amd: Fix device table setup in kdump kernels Joerg Roedel
2 siblings, 0 replies; 5+ messages in thread
From: Matt Fleming @ 2026-10-13 12:19 UTC (permalink / raw)
To: Joerg Roedel
Cc: Suravee Suthikulpanit, Ashish Kalra, Vasant Hegde,
Sairaj Kodilkar, Ankit Soni, Baoquan He, iommu, linux-kernel,
stable, kernel-team, Matt Fleming
From: Matt Fleming <mfleming@cloudflare.com>
Commit 38e5f33ee359 ("iommu/amd: Reuse device table for kdump") made
iommu_set_device_table() return early in every kdump kernel. That is
needed when the previous kernel's device table is reused: the base
register already points at it, and on SNP-enabled systems the register
is locked.
But if reuse isn't possible, early_enable_iommus() falls back to the
freshly allocated table and calls early_enable_iommu(). Because of the
early return, that table is never written to the base register. The
IOMMU keeps using whatever table the register pointed at before, while
the driver writes entries into the new one.
Only skip the write when the previous kernel's table was reused.
Fixes: 38e5f33ee359 ("iommu/amd: Reuse device table for kdump")
Cc: stable@vger.kernel.org
Reviewed-by: Ashish Kalra <ashish.kalra@amd.com>
Reviewed-by: Ankit Soni <Ankit.Soni@amd.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
Signed-off-by: Matt Fleming <mfleming@cloudflare.com>
---
drivers/iommu/amd/init.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
index c07c3a01b978..0572e1a674f0 100644
--- a/drivers/iommu/amd/init.c
+++ b/drivers/iommu/amd/init.c
@@ -409,7 +409,13 @@ static void iommu_set_device_table(struct amd_iommu *iommu)
BUG_ON(iommu->mmio_base == NULL);
- if (is_kdump_kernel())
+ /*
+ * A kdump kernel that reuses the previous kernel's device table must
+ * leave the base register alone. It already points at that table, and
+ * with SNP enabled the register is locked. If reuse failed, program
+ * the freshly allocated table like a normal boot.
+ */
+ if (iommu->pci_seg->old_dev_tbl_cpy)
return;
entry = iommu_virt_to_phys(dev_table);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] iommu/amd: Don't allocate kdump device table from DMA32
2026-10-13 12:19 [PATCH v2 0/2] iommu/amd: Fix device table setup in kdump kernels Matt Fleming
2026-10-13 12:19 ` [PATCH v2 1/2] iommu/amd: Program device table when kdump reuse fails Matt Fleming
@ 2026-10-13 12:19 ` Matt Fleming
2026-10-14 4:53 ` Vasant Hegde
2026-10-14 13:47 ` [PATCH v2 0/2] iommu/amd: Fix device table setup in kdump kernels Joerg Roedel
2 siblings, 1 reply; 5+ messages in thread
From: Matt Fleming @ 2026-10-13 12:19 UTC (permalink / raw)
To: Joerg Roedel
Cc: Suravee Suthikulpanit, Ashish Kalra, Vasant Hegde,
Sairaj Kodilkar, Ankit Soni, Baoquan He, iommu, linux-kernel,
stable, kernel-team, Matt Fleming
From: Matt Fleming <mfleming@cloudflare.com>
Booting a kdump kernel with crashkernel=X,high crashkernel=0,low on an
AMD system fails the per-segment device table allocation because there
is no memory below 4G:
swapper/0: page allocation failure: order:9, mode:0x40104(GFP_DMA32|__GFP_ZERO|__GFP_COMP)
iommu_alloc_pages_node_sz+0x7f/0x150
alloc_pci_segment+0x4bd/0x650
iommu_go_to_state+0x213d/0x34e0
amd_iommu_prepare+0x39/0xa0
irq_remapping_prepare+0x83/0xd0
enable_IR_x2apic+0x61/0x370
On our E810 systems, the kdump kernel booted but ice MSI-X interrupts
never fired and the TX queues timed out.
Commit b336781b82cc ("iommu/amd: Allocate memory below 4G for dev table
if translation pre-enabled") allocated device tables below 4G. At the
time, the kdump kernel programmed a copy of the old table into the base
register with the IOMMU still enabled. The 64-bit register is updated
as two 32-bit halves, so the running IOMMU could see a half-written,
invalid table pointer. Keeping both tables below 4G leaves the upper
half zero throughout the update, so the pointer stays valid.
Since commit 38e5f33ee359 ("iommu/amd: Reuse device table for kdump")
the kdump kernel reuses the previous kernel's table without writing the
base register, so its newly allocated table is discarded when reuse
succeeds. If reuse fails, the previous patch programs the new table only
after disabling the IOMMU. Either way, the kdump kernel's table doesn't
need to be below 4G.
The previous kernel still allocates its table from DMA32, so the kdump
kernel's check that the old table is below 4G still works. Drop
GFP_DMA32 for kdump kernels only.
Cc: <stable@vger.kernel.org> # 6.18.x
Reviewed-by: Ashish Kalra <ashish.kalra@amd.com>
Reviewed-by: Ankit Soni <Ankit.Soni@amd.com>
Signed-off-by: Matt Fleming <mfleming@cloudflare.com>
---
drivers/iommu/amd/init.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
index 0572e1a674f0..16c26d75f46f 100644
--- a/drivers/iommu/amd/init.c
+++ b/drivers/iommu/amd/init.c
@@ -648,8 +648,19 @@ static int __init find_last_devid_acpi(struct acpi_table_header *table, u16 pci_
/* Allocate per PCI segment device table */
static inline int __init alloc_dev_table(struct amd_iommu_pci_seg *pci_seg)
{
- pci_seg->dev_table = iommu_alloc_pages_sz(GFP_KERNEL | GFP_DMA32,
- pci_seg->dev_table_size);
+ gfp_t gfp = GFP_KERNEL;
+
+ /*
+ * Keep normal kernel device tables below 4G because a later kdump
+ * kernel only trusts and reuses old tables below that limit. A kdump
+ * kernel's new table is either discarded when reuse succeeds or
+ * programmed after the IOMMU is disabled, so the table does not
+ * need DMA32 memory (which the crashkernel may not have).
+ */
+ if (!is_kdump_kernel())
+ gfp |= GFP_DMA32;
+
+ pci_seg->dev_table = iommu_alloc_pages_sz(gfp, pci_seg->dev_table_size);
if (!pci_seg->dev_table)
return -ENOMEM;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] iommu/amd: Don't allocate kdump device table from DMA32
2026-10-13 12:19 ` [PATCH v2 2/2] iommu/amd: Don't allocate kdump device table from DMA32 Matt Fleming
@ 2026-10-14 4:53 ` Vasant Hegde
0 siblings, 0 replies; 5+ messages in thread
From: Vasant Hegde @ 2026-10-14 4:53 UTC (permalink / raw)
To: Matt Fleming, Joerg Roedel
Cc: Suravee Suthikulpanit, Ashish Kalra, Sairaj Kodilkar, Ankit Soni,
Baoquan He, iommu, linux-kernel, stable, kernel-team,
Matt Fleming
On 10/13/2026 5:49 PM, Matt Fleming wrote:
> From: Matt Fleming <mfleming@cloudflare.com>
>
> Booting a kdump kernel with crashkernel=X,high crashkernel=0,low on an
> AMD system fails the per-segment device table allocation because there
> is no memory below 4G:
>
> swapper/0: page allocation failure: order:9, mode:0x40104(GFP_DMA32|__GFP_ZERO|__GFP_COMP)
> iommu_alloc_pages_node_sz+0x7f/0x150
> alloc_pci_segment+0x4bd/0x650
> iommu_go_to_state+0x213d/0x34e0
> amd_iommu_prepare+0x39/0xa0
> irq_remapping_prepare+0x83/0xd0
> enable_IR_x2apic+0x61/0x370
>
> On our E810 systems, the kdump kernel booted but ice MSI-X interrupts
> never fired and the TX queues timed out.
>
> Commit b336781b82cc ("iommu/amd: Allocate memory below 4G for dev table
> if translation pre-enabled") allocated device tables below 4G. At the
> time, the kdump kernel programmed a copy of the old table into the base
> register with the IOMMU still enabled. The 64-bit register is updated
> as two 32-bit halves, so the running IOMMU could see a half-written,
> invalid table pointer. Keeping both tables below 4G leaves the upper
> half zero throughout the update, so the pointer stays valid.
>
> Since commit 38e5f33ee359 ("iommu/amd: Reuse device table for kdump")
> the kdump kernel reuses the previous kernel's table without writing the
> base register, so its newly allocated table is discarded when reuse
> succeeds. If reuse fails, the previous patch programs the new table only
> after disabling the IOMMU. Either way, the kdump kernel's table doesn't
> need to be below 4G.
>
> The previous kernel still allocates its table from DMA32, so the kdump
> kernel's check that the old table is below 4G still works. Drop
> GFP_DMA32 for kdump kernels only.
This one is OK as its regression fix. But with all the changes went in I am
wondering why we need GFP_DMA32 flag for allocation. There are only two cases
where transactions may be enabled:
- During boot (BIOS enabled DMA) : kernel will disable IOMMU before
configuring device table base address w/ new value
- During kdump : We are reusing previous kernels device table. If it fails
then kernel will disable IOMMU and re-configures it with new vlaue.
Anyway, we will look into it in detail and run more experiments. For now this
fix is fine. With that,
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
-Vasant
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/2] iommu/amd: Fix device table setup in kdump kernels
2026-10-13 12:19 [PATCH v2 0/2] iommu/amd: Fix device table setup in kdump kernels Matt Fleming
2026-10-13 12:19 ` [PATCH v2 1/2] iommu/amd: Program device table when kdump reuse fails Matt Fleming
2026-10-13 12:19 ` [PATCH v2 2/2] iommu/amd: Don't allocate kdump device table from DMA32 Matt Fleming
@ 2026-10-14 13:47 ` Joerg Roedel
2 siblings, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2026-10-14 13:47 UTC (permalink / raw)
To: Matt Fleming
Cc: Suravee Suthikulpanit, Ashish Kalra, Vasant Hegde,
Sairaj Kodilkar, Ankit Soni, Baoquan He, iommu, linux-kernel,
stable, kernel-team, Matt Fleming
On Tue, Oct 13, 2026 at 01:19:42PM +0100, Matt Fleming wrote:
> Matt Fleming (2):
> iommu/amd: Program device table when kdump reuse fails
> iommu/amd: Don't allocate kdump device table from DMA32
Applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-14 13:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13 12:19 [PATCH v2 0/2] iommu/amd: Fix device table setup in kdump kernels Matt Fleming
2026-10-13 12:19 ` [PATCH v2 1/2] iommu/amd: Program device table when kdump reuse fails Matt Fleming
2026-10-13 12:19 ` [PATCH v2 2/2] iommu/amd: Don't allocate kdump device table from DMA32 Matt Fleming
2026-10-14 4:53 ` Vasant Hegde
2026-10-14 13:47 ` [PATCH v2 0/2] iommu/amd: Fix device table setup in kdump kernels Joerg Roedel
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.