diff options
| author | Lu Baolu <baolu.lu@linux.intel.com> | 2024-02-27 10:14:41 +0800 |
|---|---|---|
| committer | Joerg Roedel <jroedel@suse.de> | 2024-03-01 13:51:21 +0100 |
| commit | def054b01a867822254e1dda13d587f5c7a99e2a (patch) | |
| tree | 5d2c0eca919c6caa0e759d9dc93f79078e07d76a /drivers/iommu/intel/iommu.h | |
| parent | 1a75cc710b956010137b4fe1d1fa3282bfd8f86c (diff) | |
| download | linux-def054b01a867822254e1dda13d587f5c7a99e2a.tar.gz linux-def054b01a867822254e1dda13d587f5c7a99e2a.tar.bz2 linux-def054b01a867822254e1dda13d587f5c7a99e2a.zip | |
iommu/vt-d: Use device rbtree in iopf reporting path
The existing I/O page fault handler currently locates the PCI device by
calling pci_get_domain_bus_and_slot(). This function searches the list
of all PCI devices until the desired device is found. To improve lookup
efficiency, replace it with device_rbtree_find() to search the device
within the probed device rbtree.
The I/O page fault is initiated by the device, which does not have any
synchronization mechanism with the software to ensure that the device
stays in the probed device tree. Theoretically, a device could be released
by the IOMMU subsystem after device_rbtree_find() and before
iopf_get_dev_fault_param(), which would cause a use-after-free problem.
Add a mutex to synchronize the I/O page fault reporting path and the IOMMU
release device path. This lock doesn't introduce any performance overhead,
as the conflict between I/O page fault reporting and device releasing is
very rare.
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20240220065939.121116-3-baolu.lu@linux.intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu/intel/iommu.h')
| -rw-r--r-- | drivers/iommu/intel/iommu.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h index 50d1e196db52..a0feab099f12 100644 --- a/drivers/iommu/intel/iommu.h +++ b/drivers/iommu/intel/iommu.h @@ -713,6 +713,8 @@ struct intel_iommu { #endif struct iopf_queue *iopf_queue; unsigned char iopfq_name[16]; + /* Synchronization between fault report and iommu device release. */ + struct mutex iopf_lock; struct q_inval *qi; /* Queued invalidation info */ u32 iommu_state[MAX_SR_DMAR_REGS]; /* Store iommu states between suspend and resume.*/ |
