• Jean-Philippe Brucker's avatar
    iommu/arm-smmu-v3: Implement iommu_sva_bind/unbind() · 32784a95
    Jean-Philippe Brucker authored
    The sva_bind() function allows devices to access process address spaces
    using a PASID (aka SSID).
    
    (1) bind() allocates or gets an existing MMU notifier tied to the
        (domain, mm) pair. Each mm gets one PASID.
    
    (2) Any change to the address space calls invalidate_range() which sends
        ATC invalidations (in a subsequent patch).
    
    (3) When the process address space dies, the release() notifier disables
        the CD to allow reclaiming the page tables. Since release() has to
        be light we do not instruct device drivers to stop DMA here, we just
        ignore incoming page faults from this point onwards.
    
        To avoid any event 0x0a print (C_BAD_CD) we disable translation
        without clearing CD.V. PCIe Translation Requests and Page Requests
        are silently denied. Don't clear the R bit because the S bit can't
        be cleared when STALL_MODEL==0b10 (forced), and clearing R without
        clearing S is useless. Faulting transactions will stall and will be
        aborted by the IOPF handler.
    
    (4) After stopping DMA, the device driver releases the bond by calling
        unbind(). We release the MMU notifier, free the PASID and the bond.
    
    Three structures keep track of bonds:
    * arm_smmu_bond: one per {device, mm} pair, the handle returned to the
      device driver for a bind() request.
    * arm_smmu_mmu_notifier: one per {domain, mm} pair, deals with ATS/TLB
      invalidations and clearing the context descriptor on mm exit.
    * arm_smmu_ctx_desc: one per mm, holds the pinned ASID and pgd.
    Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe@linaro.org>
    Link: https://lore.kernel.org/r/20201106155048.997886-4-jean-philippe@linaro.orgSigned-off-by: default avatarWill Deacon <will@kernel.org>
    32784a95
Kconfig 11.9 KB