Skip to content

iommu/amd: Fix race conditions around increase_address_space()

Joerg Roedel linux-iommu lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5iommu/amd: Fix race in increase_address_space()/fetch_pte()drivers/iommu/amd_iommu.c drivers/iommu/amd_iommu_types.h+112 -370 replies
2/5iommu/amd: Do not loop forever when trying to increase address spacedrivers/iommu/amd_iommu.c+12 -10 replies
3/5iommu/amd: Call domain_flush_complete() in update_domain()drivers/iommu/amd_iommu.c+1 -00 replies
4/5iommu/amd: Update Device Table in increase_address_space()drivers/iommu/amd_iommu.c+36 -130 replies
5/5iommu/amd: Do not flush Device Table in iommu_map_page()drivers/iommu/amd_iommu.c+16 -110 replies

Reviews trailers per patch

None of the 5 patches has a Reviewed-by or Acked-by.

PatchQian Cai
1/5T-b
2/5T-b
3/5T-b
4/5T-b
5/5T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/5] iommu/amd: Fix race conditions around increase_address_space()

Hi,

Qian reported more race conditions around the dma-mapping code path in the AMD IOMMU driver. The race condtions are between increas_address_space() and fetch_pte(), there were two of them:

1) the 'pt_root' and 'mode' fields of 'struct protection_domain' relate to each other so that they must be updated together atomically.

2) The increase_address_space() function publishes the updated page-table before it has been written to the DTE. This might cause PTEs to be mapped and addresses handed to the device which are not yet reachable through the DTE entry, causing IO page-faults.

This patch-set fixes these issues, as tested by Qian Cai.

Thanks a lot again for reporting these issued and testing the fixes!

Regards,

Joerg

Joerg Roedel (5):
iommu/amd: Fix race in increase_address_space()/fetch_pte() iommu/amd: Do not loop forever when trying to increase address space iommu/amd: Call domain_flush_complete() in update_domain() iommu/amd: Update Device Table in increase_address_space() iommu/amd: Do not flush Device Table in iommu_map_page()

 drivers/iommu/amd_iommu.c       | 198 +++++++++++++++++++++++++-------
 drivers/iommu/amd_iommu_types.h |   9 +-
 2 files changed, 161 insertions(+), 46 deletions(-)
Signature · 6 lines
2.17.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu