Skip to content

iommu/amd: Lock the device table by DeviceID

Vasant Hegde linux-iommu 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3iommu/amd: Serialize device-table writes with one per-segment lockdrivers/iommu/amd/amd_iommu_types.h drivers/iommu/amd/init.c drivers/iommu/amd/iommu.c+12 -130 replies
2/3iommu/amd: Identify a DTE entry by its DeviceIDdrivers/iommu/amd/iommu.c+15 -160 replies
3/3iommu/amd: Drop the iommu_dev_data allocation for alias devicesdrivers/iommu/amd/iommu.c+4 -230 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/3] iommu/amd: Lock the device table by DeviceID

The device table is indexed by DeviceID, but the lock that protects a write lives in iommu_dev_data. A DTE can therefore be updated with no lock when no dev_data exists. set_dte_irq_entry() skips the lock when search_dev_data() returns NULL, and clone_alias() allocates a dev_data for an alias DeviceID only so that it has a lock to take. That alias object is never attached to a domain and never freed.

Move dte_lock to the PCI segment so every writer takes the same lock. Address each slot by DeviceID instead of by a dev_data pointer, and drop the alias allocation. A DTE update is not a fast path, so one lock per segment is enough.

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

Vasant Hegde (3):
iommu/amd: Serialize device-table writes with one per-segment lock iommu/amd: Identify a DTE entry by its DeviceID iommu/amd: Drop the iommu_dev_data allocation for alias devices

 drivers/iommu/amd/amd_iommu_types.h |  2 +-
 drivers/iommu/amd/init.c            |  1 +
 drivers/iommu/amd/iommu.c           | 76 ++++++++++-------------------
 3 files changed, 29 insertions(+), 50 deletions(-)
Signature · 1 line
2.31.1