1. 04 6月, 2020 1 次提交
  2. 29 5月, 2020 2 次提交
    • Q
      iommu: Fix reference count leak in iommu_group_alloc. · 7cc31613
      Qiushi Wu 提交于
      kobject_init_and_add() takes reference even when it fails.
      Thus, when kobject_init_and_add() returns an error,
      kobject_put() must be called to properly clean up the kobject.
      
      Fixes: d72e31c9 ("iommu: IOMMU Groups")
      Signed-off-by: NQiushi Wu <wu000273@umn.edu>
      Link: https://lore.kernel.org/r/20200527210020.6522-1-wu000273@umn.eduSigned-off-by: NJoerg Roedel <jroedel@suse.de>
      7cc31613
    • 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
  3. 25 5月, 2020 2 次提交
  4. 19 5月, 2020 1 次提交
    • J
      iommu: Fix deferred domain attachment · bd421264
      Joerg Roedel 提交于
      The IOMMU core code has support for deferring the attachment of a domain
      to a device. This is needed in kdump kernels where the new domain must
      not be attached to a device before the device driver takes it over.
      
      When the AMD IOMMU driver got converted to use the dma-iommu
      implementation, the deferred attaching got lost. The code in
      dma-iommu.c has support for deferred attaching, but it calls into
      iommu_attach_device() to actually do it. But iommu_attach_device()
      will check if the device should be deferred in it code-path and do
      nothing, breaking deferred attachment.
      
      Move the is_deferred_attach() check out of the attach_device path and
      into iommu_group_add_device() to make deferred attaching work from the
      dma-iommu code.
      
      Fixes: 795bbbb9 ("iommu/dma-iommu: Handle deferred devices")
      Reported-by: NJerry Snitselaar <jsnitsel@redhat.com>
      Suggested-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      Tested-by: NJerry Snitselaar <jsnitsel@redhat.com>
      Cc: Jerry Snitselaar <jsnitsel@redhat.com>
      Cc: Tom Murphy <murphyt7@tcd.ie>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Link: https://lore.kernel.org/r/20200519130340.14564-1-joro@8bytes.org
      bd421264
  5. 15 5月, 2020 1 次提交
  6. 13 5月, 2020 1 次提交
  7. 05 5月, 2020 12 次提交
  8. 01 5月, 2020 1 次提交
  9. 29 4月, 2020 1 次提交
    • K
      iommu: Fix the memory leak in dev_iommu_free() · 5375e874
      Kevin Hao 提交于
      In iommu_probe_device(), we would invoke dev_iommu_free() to free the
      dev->iommu after the ->add_device() returns failure. But after commit
      72acd9df ("iommu: Move iommu_fwspec to struct dev_iommu"), we also
      need to free the iommu_fwspec before the dev->iommu is freed. This fixes
      the following memory leak reported by kmemleak:
        unreferenced object 0xffff000bc836c700 (size 128):
          comm "swapper/0", pid 1, jiffies 4294896304 (age 782.120s)
          hex dump (first 32 bytes):
            00 00 00 00 00 00 00 00 d8 cd 9b ff 0b 00 ff ff  ................
            00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          backtrace:
            [<00000000df34077b>] kmem_cache_alloc_trace+0x244/0x4b0
            [<000000000e560ac0>] iommu_fwspec_init+0x7c/0xb0
            [<0000000075eda275>] of_iommu_xlate+0x80/0xe8
            [<00000000728d6bf9>] of_pci_iommu_init+0xb0/0xb8
            [<00000000d001fe6f>] pci_for_each_dma_alias+0x48/0x190
            [<000000006db6bbce>] of_iommu_configure+0x1ac/0x1d0
            [<00000000634745f8>] of_dma_configure+0xdc/0x220
            [<000000002cbc8ba0>] pci_dma_configure+0x50/0x78
            [<00000000cdf6e193>] really_probe+0x8c/0x340
            [<00000000fddddc46>] driver_probe_device+0x60/0xf8
            [<0000000061bcdb51>] __device_attach_driver+0x8c/0xd0
            [<000000009b9ff58e>] bus_for_each_drv+0x80/0xd0
            [<000000004b9c8aa3>] __device_attach+0xec/0x148
            [<00000000a5c13bf3>] device_attach+0x1c/0x28
            [<000000005071e151>] pci_bus_add_device+0x58/0xd0
            [<000000002d4f87d1>] pci_bus_add_devices+0x40/0x90
      
      Fixes: 72acd9df ("iommu: Move iommu_fwspec to struct dev_iommu")
      Signed-off-by: NKevin Hao <haokexin@gmail.com>
      Link: https://lore.kernel.org/r/20200402143749.40500-1-haokexin@gmail.comSigned-off-by: NJoerg Roedel <jroedel@suse.de>
      5375e874
  10. 27 3月, 2020 2 次提交
  11. 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
  12. 08 1月, 2020 1 次提交
  13. 23 12月, 2019 4 次提交
  14. 17 12月, 2019 2 次提交
  15. 15 10月, 2019 3 次提交
  16. 03 9月, 2019 1 次提交
  17. 30 8月, 2019 2 次提交
  18. 23 8月, 2019 2 次提交