• Lu Baolu's avatar
    iommu/vt-d: Disable non-recoverable fault processing before unbind · 37e91bd4
    Lu Baolu authored
    When a PASID is used for SVA by the device, it's possible that the PASID
    entry is cleared before the device flushes all ongoing DMA requests. The
    IOMMU should tolerate and ignore the non-recoverable faults caused by the
    untranslated requests from this device.
    
    For example, when an exception happens, the process terminates before the
    device driver stops DMA and call IOMMU driver to unbind PASID. The flow
    of process exist is as follows:
    
    do_exit() {
         exit_mm() {
                 mm_put();
                 exit_mmap() {
                         intel_invalidate_range() //mmu notifier
                         tlb_finish_mmu()
                         mmu_notifier_release(mm) {
                                 intel_iommu_release() {
    [2]                                  intel_iommu_teardown_pasid();
                                         intel_iommu_flush_tlbs();
                                 }
                         }
                         unmap_vmas();
                         free_pgtables();
                 };
         }
         exit_files(tsk) {
                 close_files() {
                         dsa_close();
    [1]                  dsa_stop_dma();
                         intel_svm_unbind_pasid();
                 }
         }
    }
    
    Care must be taken on VT-d to avoid unrecoverable faults between the time
    window of [1] and [2]. [Process exist flow was contributed by Jacob Pan.]
    
    Intel VT-d provides such function through the FPD bit of the PASID entry.
    This sets FPD bit when PASID entry is changing from present to nonpresent
    in the mm notifier and will clear it when the pasid is unbound.
    Signed-off-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
    Reviewed-by: default avatarJacob Pan <jacob.jun.pan@linux.intel.com>
    Link: https://lore.kernel.org/r/20200516062101.29541-15-baolu.lu@linux.intel.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
    37e91bd4
intel-pasid.c 20.4 KB