• Lu Baolu's avatar
    iommu/vt-d: Use device rbtree in iopf reporting path · def054b0
    Lu Baolu authored
    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: default avatarLu Baolu <baolu.lu@linux.intel.com>
    Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
    Link: https://lore.kernel.org/r/20240220065939.121116-3-baolu.lu@linux.intel.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
    def054b0
iommu.h 36.7 KB