FAILED: patch "[PATCH] iommu/amd: Fix I/O page table memory leak" failed to apply to 5.15-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 6b0b2d9a6a308bcd9300c2d83000a82812c56cea Mon Sep 17 00:00:00 2001
From: Suravee Suthikulpanit <[email protected]>
Date: Thu, 10 Feb 2022 09:47:45 -0600
Subject: [PATCH] iommu/amd: Fix I/O page table memory leak
The current logic updates the I/O page table mode for the domain before calling the logic to free memory used for the page table. This results in IOMMU page table memory leak, and can be observed when launching VM w/ pass-through devices.
Fix by freeing the memory used for page table before updating the mode.
drivers/iommu/amd/io_pgtable.c +6 -6
@@ -492,18 +492,18 @@ static void v1_free_pgtable(struct io_pgtable *iop) dom = container_of(pgtable, struct protection_domain, iop); -/* Update data structure */ -amd_iommu_domain_clr_pt_root (dom); - -/* Make changes visible to IOMMUs */ -amd_iommu_domain_update (dom); -/* Page-table is not visible to IOMMU anymore, so free it */ BUG_ON (pgtable->mode <PAGE_MODE_NONE || pgtable->mode >PAGE_MODE_6_LEVEL );free_sub_pt (pgtable->root, pgtable->mode, &freelist); +/* Update data structure */ +amd_iommu_domain_clr_pt_root (dom); + +/* Make changes visible to IOMMUs */ +amd_iommu_domain_update (dom); +put_pages_list (&freelist); }