Skip to content

iommu/amd: Fix GCR3 lifetime and PPR completion

Vasant Hegde linux-iommu stable 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest12 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12iommu/amd: Disable PRI before ATS and PASIDdrivers/iommu/amd/iommu.c+1 -10 replies
2/12iommu/amd: Derive the PPR completion GN bit from the requestdrivers/iommu/amd/amd_iommu.h drivers/iommu/amd/iommu.c drivers/iommu/amd/ppr.c+15 -210 replies
3/12iommu/amd: Complete a PPR from a device the IOMMU did not probedrivers/iommu/amd/amd_iommu.h drivers/iommu/amd/iommu.c drivers/iommu/amd/ppr.c+30 -280 replies
4/12iommu/amd: Keep the GCR3 table while PASIDs are attacheddrivers/iommu/amd/iommu.c+5 -40 replies
5/12iommu/amd: Restore an SVA PASID after PCI resetdrivers/iommu/amd/pasid.c+6 -10 replies
6/12iommu/amd: Disable GCR3 entries from the SVA mm release notifierdrivers/iommu/amd/amd_iommu.h drivers/iommu/amd/iommu.c drivers/iommu/amd/pasid.c+21 -50 replies
7/12iommu/amd: Complete an aborted PPR group only on its last pagedrivers/iommu/amd/ppr.c+11 -40 replies
8/12iommu/amd: Discard partial page requests when the PPR log overflowsdrivers/iommu/amd/ppr.c+15 -00 replies
9/12iommu/amd: Allocate the GCR3 table from the devicedrivers/iommu/amd/iommu.c+58 -500 replies
10/12iommu/amd: Return -ENOMEM when SVA PASID allocation failsdrivers/iommu/amd/pasid.c+1 -10 replies
11/12iommu/amd: Drain the PPR log before detaching an SVA PASIDdrivers/iommu/amd/amd_iommu.h drivers/iommu/amd/amd_iommu_types.h drivers/iommu/amd/init.c +2 more+41 -20 replies
12/12iommu/amd: Drain the PPR log before removing a device from the IOPF queuedrivers/iommu/amd/iommu.c+12 -120 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/12] iommu/amd: Fix GCR3 lifetime and PPR completion

This series fixes a number of issues in the SVA/PRI path. It does not address all of them: a follow-up series will move PASID/PRI enablement to the probe/release path and fix the remaining PRI issues.

Note that this series also does not fully address the issue during
the mmu_notifier release path, which was discussed in an earlier thread [1]. We are still running some experiments internally, and I intend to address it in v2.
[1] https://lore.kernel.org/linux-iommu/[email protected]/

Summary of changes:
-------------------
SVA teardown and page-request completion have several ordering bugs. The GCR3 table can be freed while PASIDs are still attached, and a PPR response can complete the wrong request or run after its attach handle is gone.

- amd_iommu_complete_ppr() takes the GN bit from the request. Page-table mode does not cover passthrough, which also uses PASID.

- The GCR3 table stays allocated while PASIDs are attached, so the blocked-domain attach during PCI reset does not free the root out from under a later clear. A PASID-capable device allocates the table at probe and frees it at release. A non-PASID v2 domain still allocates it on attach and frees it on detach. The mm release notifier only disables GCR3 entries and leaves the PASID attachment for the core to remove. After reset, a blocking old domain is programmed again as a fresh SVA attach. A failed tracking allocation returns -ENOMEM.

- An aborted multi-page group is completed only on its last page. Overflow discards partial groups whose last page never reached the log. Detach drains the PPR log before the SVA attach handle is freed, and before a device is removed from the IOPF queue. The DTE is cleared first so the IOMMU stops logging new requests, and PCI capabilities are disabled after those requests have been answered.

Full series including other cleanup is available at:
https://github.com/AMDESE/linux-iommu/tree/iommu_code_audit_7.4_v1

Santosh Shukla (1):
iommu/amd: Restore an SVA PASID after PCI reset

Vasant Hegde (11):
iommu/amd: Disable PRI before ATS and PASID
iommu/amd: Derive the PPR completion GN bit from the request iommu/amd: Complete a PPR from a device the IOMMU did not probe iommu/amd: Keep the GCR3 table while PASIDs are attached iommu/amd: Disable GCR3 entries from the SVA mm release notifier iommu/amd: Complete an aborted PPR group only on its last page iommu/amd: Discard partial page requests when the PPR log overflows iommu/amd: Allocate the GCR3 table from the device iommu/amd: Return -ENOMEM when SVA PASID allocation fails iommu/amd: Drain the PPR log before detaching an SVA PASID iommu/amd: Drain the PPR log before removing a device from the IOPF
queue

 drivers/iommu/amd/amd_iommu.h       |   5 +-
 drivers/iommu/amd/amd_iommu_types.h |   2 +
 drivers/iommu/amd/init.c            |   1 +
 drivers/iommu/amd/iommu.c           | 187 +++++++++++++---------------
 drivers/iommu/amd/pasid.c           |  32 +++--
 drivers/iommu/amd/ppr.c             |  92 ++++++++++++--
 6 files changed, 203 insertions(+), 116 deletions(-)
Signature · 1 line
2.31.1