1. 27 1月, 2021 2 次提交
  2. 25 11月, 2020 2 次提交
  3. 01 10月, 2020 2 次提交
  4. 18 9月, 2020 1 次提交
  5. 04 9月, 2020 1 次提交
  6. 09 7月, 2020 1 次提交
  7. 30 6月, 2020 1 次提交
  8. 29 5月, 2020 1 次提交
    • J
      iommu: Remove iommu_sva_ops::mm_exit() · edcc40d2
      Jean-Philippe Brucker 提交于
      After binding a device to an mm, device drivers currently need to
      register a mm_exit handler. This function is called when the mm exits,
      to gracefully stop DMA targeting the address space and flush page faults
      to the IOMMU.
      
      This is deemed too complex for the MMU release() notifier, which may be
      triggered by any mmput() invocation, from about 120 callsites [1]. The
      upcoming SVA module has an example of such complexity: the I/O Page
      Fault handler would need to call mmput_async() instead of mmput() after
      handling an IOPF, to avoid triggering the release() notifier which would
      in turn drain the IOPF queue and lock up.
      
      Another concern is the DMA stop function taking too long, up to several
      minutes [2]. For some mmput() callers this may disturb other users. For
      example, if the OOM killer picks the mm bound to a device as the victim
      and that mm's memory is locked, if the release() takes too long, it
      might choose additional innocent victims to kill.
      
      To simplify the MMU release notifier, don't forward the notification to
      device drivers. Since they don't stop DMA on mm exit anymore, the PASID
      lifetime is extended:
      
      (1) The device driver calls bind(). A PASID is allocated.
      
        Here any DMA fault is handled by mm, and on error we don't print
        anything to dmesg. Userspace can easily trigger errors by issuing DMA
        on unmapped buffers.
      
      (2) exit_mmap(), for example the process took a SIGKILL. This step
          doesn't happen during normal operations. Remove the pgd from the
          PASID table, since the page tables are about to be freed. Invalidate
          the IOTLBs.
      
        Here the device may still perform DMA on the address space. Incoming
        transactions are aborted but faults aren't printed out. ATS
        Translation Requests return Successful Translation Completions with
        R=W=0. PRI Page Requests return with Invalid Request.
      
      (3) The device driver stops DMA, possibly following release of a fd, and
          calls unbind(). PASID table is cleared, IOTLB invalidated if
          necessary. The page fault queues are drained, and the PASID is
          freed.
      
        If DMA for that PASID is still running here, something went seriously
        wrong and errors should be reported.
      
      For now remove iommu_sva_ops entirely. We might need to re-introduce
      them at some point, for example to notify device drivers of unhandled
      IOPF.
      
      [1] https://lore.kernel.org/linux-iommu/20200306174239.GM31668@ziepe.ca/
      [2] https://lore.kernel.org/linux-iommu/4d68da96-0ad5-b412-5987-2f7a6aa796c3@amd.com/Signed-off-by: NJean-Philippe Brucker <jean-philippe@linaro.org>
      Acked-by: NJacob Pan <jacob.jun.pan@linux.intel.com>
      Acked-by: NLu Baolu <baolu.lu@linux.intel.com>
      Link: https://lore.kernel.org/r/20200423125329.782066-3-jean-philippe@linaro.orgSigned-off-by: NJoerg Roedel <jroedel@suse.de>
      edcc40d2
  9. 15 5月, 2020 1 次提交
  10. 13 5月, 2020 1 次提交
  11. 05 5月, 2020 5 次提交
  12. 27 3月, 2020 5 次提交
  13. 28 2月, 2020 1 次提交
    • R
      iommu: Use C99 flexible array in fwspec · 098accf2
      Robin Murphy 提交于
      Although the 1-element array was a typical pre-C99 way to implement
      variable-length structures, and indeed is a fundamental construct in the
      APIs of certain other popular platforms, there's no good reason for it
      here (and in particular the sizeof() trick is far too "clever" for its
      own good). We can just as easily implement iommu_fwspec's preallocation
      behaviour using a standard flexible array member, so let's make it look
      the way most readers would expect.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      098accf2
  14. 16 1月, 2020 1 次提交
  15. 10 1月, 2020 1 次提交
  16. 23 12月, 2019 2 次提交
  17. 07 11月, 2019 1 次提交
    • W
      iommu/io-pgtable-arm: Rename IOMMU_QCOM_SYS_CACHE and improve doc · dd5ddd3c
      Will Deacon 提交于
      The 'IOMMU_QCOM_SYS_CACHE' IOMMU protection flag is exposed to all
      users of the IOMMU API. Despite its name, the idea behind it isn't
      especially tied to Qualcomm implementations and could conceivably be
      used by other systems.
      
      Rename it to 'IOMMU_SYS_CACHE_ONLY' and update the comment to describe
      a bit better the idea behind it.
      
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: "Isaac J. Manjarres" <isaacm@codeaurora.org>
      Signed-off-by: NWill Deacon <will@kernel.org>
      dd5ddd3c
  18. 15 10月, 2019 3 次提交
  19. 23 8月, 2019 1 次提交
  20. 30 7月, 2019 1 次提交
    • W
      iommu: Pass struct iommu_iotlb_gather to ->unmap() and ->iotlb_sync() · 56f8af5e
      Will Deacon 提交于
      To allow IOMMU drivers to batch up TLB flushing operations and postpone
      them until ->iotlb_sync() is called, extend the prototypes for the
      ->unmap() and ->iotlb_sync() IOMMU ops callbacks to take a pointer to
      the current iommu_iotlb_gather structure.
      
      All affected IOMMU drivers are updated, but there should be no
      functional change since the extra parameter is ignored for now.
      Signed-off-by: NWill Deacon <will@kernel.org>
      56f8af5e
  21. 24 7月, 2019 3 次提交
    • W
      iommu: Introduce iommu_iotlb_gather_add_page() · 4fcf8544
      Will Deacon 提交于
      Introduce a helper function for drivers to use when updating an
      iommu_iotlb_gather structure in response to an ->unmap() call, rather
      than having to open-code the logic in every page-table implementation.
      Signed-off-by: NWill Deacon <will@kernel.org>
      4fcf8544
    • W
      iommu: Introduce struct iommu_iotlb_gather for batching TLB flushes · a7d20dc1
      Will Deacon 提交于
      To permit batching of TLB flushes across multiple calls to the IOMMU
      driver's ->unmap() implementation, introduce a new structure for
      tracking the address range to be flushed and the granularity at which
      the flushing is required.
      
      This is hooked into the IOMMU API and its caller are updated to make use
      of the new structure. Subsequent patches will plumb this into the IOMMU
      drivers as well, but for now the gathering information is ignored.
      Signed-off-by: NWill Deacon <will@kernel.org>
      a7d20dc1
    • W
      iommu: Remove empty iommu_tlb_range_add() callback from iommu_ops · 6d1bcb95
      Will Deacon 提交于
      Commit add02cfd ("iommu: Introduce Interface for IOMMU TLB Flushing")
      added three new TLB flushing operations to the IOMMU API so that the
      underlying driver operations can be batched when unmapping large regions
      of IO virtual address space.
      
      However, the ->iotlb_range_add() callback has not been implemented by
      any IOMMU drivers (amd_iommu.c implements it as an empty function, which
      incurs the overhead of an indirect branch). Instead, drivers either flush
      the entire IOTLB in the ->iotlb_sync() callback or perform the necessary
      invalidation during ->unmap().
      
      Attempting to implement ->iotlb_range_add() for arm-smmu-v3.c revealed
      two major issues:
      
        1. The page size used to map the region in the page-table is not known,
           and so it is not generally possible to issue TLB flushes in the most
           efficient manner.
      
        2. The only mutable state passed to the callback is a pointer to the
           iommu_domain, which can be accessed concurrently and therefore
           requires expensive synchronisation to keep track of the outstanding
           flushes.
      
      Remove the callback entirely in preparation for extending ->unmap() and
      ->iotlb_sync() to update a token on the caller's stack.
      Signed-off-by: NWill Deacon <will@kernel.org>
      6d1bcb95
  22. 19 6月, 2019 1 次提交
    • V
      iommu/io-pgtable-arm: Add support to use system cache · 90ec7a76
      Vivek Gautam 提交于
      Few Qualcomm platforms such as, sdm845 have an additional outer
      cache called as System cache, aka. Last level cache (LLC) that
      allows non-coherent devices to upgrade to using caching.
      This cache sits right before the DDR, and is tightly coupled
      with the memory controller. The clients using this cache request
      their slices from this system cache, make it active, and can then
      start using it.
      
      There is a fundamental assumption that non-coherent devices can't
      access caches. This change adds an exception where they *can* use
      some level of cache despite still being non-coherent overall.
      The coherent devices that use cacheable memory, and CPU make use of
      this system cache by default.
      
      Looking at memory types, we have following -
      a) Normal uncached :- MAIR 0x44, inner non-cacheable,
                            outer non-cacheable;
      b) Normal cached :-   MAIR 0xff, inner read write-back non-transient,
                            outer read write-back non-transient;
                            attribute setting for coherenet I/O devices.
      and, for non-coherent i/o devices that can allocate in system cache
      another type gets added -
      c) Normal sys-cached :- MAIR 0xf4, inner non-cacheable,
                              outer read write-back non-transient
      
      Coherent I/O devices use system cache by marking the memory as
      normal cached.
      Non-coherent I/O devices should mark the memory as normal
      sys-cached in page tables to use system cache.
      Acked-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NVivek Gautam <vivek.gautam@codeaurora.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      90ec7a76
  23. 12 6月, 2019 2 次提交
    • E
      iommu: Introduce IOMMU_RESV_DIRECT_RELAXABLE reserved memory regions · adfd3738
      Eric Auger 提交于
      Introduce a new type for reserved region. This corresponds
      to directly mapped regions which are known to be relaxable
      in some specific conditions, such as device assignment use
      case. Well known examples are those used by USB controllers
      providing PS/2 keyboard emulation for pre-boot BIOS and
      early BOOT or RMRRs associated to IGD working in legacy mode.
      
      Since commit c875d2c1 ("iommu/vt-d: Exclude devices using RMRRs
      from IOMMU API domains") and commit 18436afd ("iommu/vt-d: Allow
      RMRR on graphics devices too"), those regions are currently
      considered "safe" with respect to device assignment use case
      which requires a non direct mapping at IOMMU physical level
      (RAM GPA -> HPA mapping).
      
      Those RMRRs currently exist and sometimes the device is
      attempting to access it but this has not been considered
      an issue until now.
      
      However at the moment, iommu_get_group_resv_regions() is
      not able to make any difference between directly mapped
      regions: those which must be absolutely enforced and those
      like above ones which are known as relaxable.
      
      This is a blocker for reporting severe conflicts between
      non relaxable RMRRs (like MSI doorbells) and guest GPA space.
      
      With this new reserved region type we will be able to use
      iommu_get_group_resv_regions() to enumerate the IOVA space
      that is usable through the IOMMU API without introducing
      regressions with respect to existing device assignment
      use cases (USB and IGD).
      Signed-off-by: NEric Auger <eric.auger@redhat.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      adfd3738
    • J
      iommu: Add recoverable fault reporting · bf3255b3
      Jean-Philippe Brucker 提交于
      Some IOMMU hardware features, for example PCI PRI and Arm SMMU Stall,
      enable recoverable I/O page faults. Allow IOMMU drivers to report PRI Page
      Requests and Stall events through the new fault reporting API. The
      consumer of the fault can be either an I/O page fault handler in the host,
      or a guest OS.
      
      Once handled, the fault must be completed by sending a page response back
      to the IOMMU. Add an iommu_page_response() function to complete a page
      fault.
      
      There are two ways to extend the userspace API:
      * Add a field to iommu_page_response and a flag to
        iommu_page_response::flags describing the validity of this field.
      * Introduce a new iommu_page_response_X structure with a different version
        number. The kernel must then support both versions.
      Signed-off-by: NJacob Pan <jacob.jun.pan@linux.intel.com>
      Signed-off-by: NJean-Philippe Brucker <jean-philippe.brucker@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      bf3255b3