1. 20 10月, 2017 9 次提交
  2. 01 9月, 2017 3 次提交
  3. 31 8月, 2017 2 次提交
    • J
      iommu/vt-d: Prevent VMD child devices from being remapping targets · 5823e330
      Jon Derrick 提交于
      VMD child devices must use the VMD endpoint's ID as the requester.  Because
      of this, there needs to be a way to link the parent VMD endpoint's IOMMU
      group and associated mappings to the VMD child devices such that attaching
      and detaching child devices modify the endpoint's mappings, while
      preventing early detaching on a singular device removal or unbinding.
      
      The reassignment of individual VMD child devices devices to VMs is outside
      the scope of VMD, but may be implemented in the future. For now it is best
      to prevent any such attempts.
      
      Prevent VMD child devices from returning an IOMMU, which prevents it from
      exposing an iommu_group sysfs directory and allowing subsequent binding by
      userspace-access drivers such as VFIO.
      Signed-off-by: NJon Derrick <jonathan.derrick@intel.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      5823e330
    • J
      iommu: Introduce Interface for IOMMU TLB Flushing · add02cfd
      Joerg Roedel 提交于
      With the current IOMMU-API the hardware TLBs have to be
      flushed in every iommu_ops->unmap() call-back.
      
      For unmapping large amounts of address space, like it
      happens when a KVM domain with assigned devices is
      destroyed, this causes thousands of unnecessary TLB flushes
      in the IOMMU hardware because the unmap call-back runs for
      every unmapped physical page.
      
      With the TLB Flush Interface and the new iommu_unmap_fast()
      function introduced here the need to clean the hardware TLBs
      is removed from the unmapping code-path. Users of
      iommu_unmap_fast() have to explicitly call the TLB-Flush
      functions to sync the page-table changes to the hardware.
      
      Three functions for TLB-Flushes are introduced:
      
      	* iommu_flush_tlb_all() - Flushes all TLB entries
      	                          associated with that
      				  domain. TLBs entries are
      				  flushed when this function
      				  returns.
      
      	* iommu_tlb_range_add() - This will add a given
      				  range to the flush queue
      				  for this domain.
      
      	* iommu_tlb_sync() - Flushes all queued ranges from
      			     the hardware TLBs. Returns when
      			     the flush is finished.
      
      The semantic of this interface is intentionally similar to
      the iommu_gather_ops from the io-pgtable code.
      
      Cc: Alex Williamson <alex.williamson@redhat.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      add02cfd
  4. 30 8月, 2017 7 次提交
  5. 28 8月, 2017 5 次提交
    • J
      iommu/amd: Rename a few flush functions · 0688a099
      Joerg Roedel 提交于
      Rename a few iommu cache-flush functions that start with
      iommu_ to start with amd_iommu now. This is to prevent name
      collisions with generic iommu code later on.
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      0688a099
    • B
      iommu/amd: Check if domain is NULL in get_domain() and return -EBUSY · ec62b1ab
      Baoquan He 提交于
      In get_domain(), 'domain' could be NULL before it's passed to dma_ops_domain()
      to dereference. And the current code calling get_domain() can't deal with the
      returned 'domain' well if its value is NULL.
      
      So before dma_ops_domain() calling, check if 'domain' is NULL, If yes just return
      ERR_PTR(-EBUSY) directly.
      Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
      Fixes: df3f7a6e ('iommu/amd: Use is_attach_deferred call-back')
      Signed-off-by: NBaoquan He <bhe@redhat.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      ec62b1ab
    • Y
      iommu/mediatek: Fix a build warning of BIT(32) in ARM · 41939980
      Yong Wu 提交于
      The commit ("iommu/mediatek: Enlarge the validate PA range
      for 4GB mode") introduce the following build warning while ARCH=arm:
      
         drivers/iommu/mtk_iommu.c: In function 'mtk_iommu_iova_to_phys':
         include/linux/bitops.h:6:24: warning: left shift count >= width
      of type [-Wshift-count-overflow]
          #define BIT(nr)   (1UL << (nr))
                                 ^
      >> drivers/iommu/mtk_iommu.c:407:9: note: in expansion of macro 'BIT'
            pa |= BIT(32);
      
        drivers/iommu/mtk_iommu.c: In function 'mtk_iommu_probe':
         include/linux/bitops.h:6:24: warning: left shift count >= width
      of type [-Wshift-count-overflow]
          #define BIT(nr)   (1UL << (nr))
                                 ^
         drivers/iommu/mtk_iommu.c:589:35: note: in expansion of macro 'BIT'
           data->enable_4GB = !!(max_pfn > (BIT(32) >> PAGE_SHIFT));
      
      Use BIT_ULL instead of BIT.
      Reported-by: Nkernel test robot <lkp@intel.com>
      Signed-off-by: NYong Wu <yong.wu@mediatek.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      41939980
    • Y
      iommu/mediatek: Fix a build fail of m4u_type · 4f1c8ea1
      Yong Wu 提交于
      The commit ("iommu/mediatek: Enlarge the validate PA range
      for 4GB mode") introduce the following build error:
      
         drivers/iommu/mtk_iommu.c: In function 'mtk_iommu_hw_init':
      >> drivers/iommu/mtk_iommu.c:536:30: error: 'const struct mtk_iommu_data'
       has no member named 'm4u_type'; did you mean 'm4u_dom'?
           if (data->enable_4GB && data->m4u_type != M4U_MT8173) {
      
      This patch fix it, use "m4u_plat" instead of "m4u_type".
      Reported-by: Nkernel test robot <lkp@intel.com>
      Signed-off-by: NYong Wu <yong.wu@mediatek.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      4f1c8ea1
    • A
      iommu: qcom: annotate PM functions as __maybe_unused · 6ce5b0f2
      Arnd Bergmann 提交于
      The qcom_iommu_disable_clocks() function is only called from PM
      code that is hidden in an #ifdef, causing a harmless warning without
      CONFIG_PM:
      
      drivers/iommu/qcom_iommu.c:601:13: error: 'qcom_iommu_disable_clocks' defined but not used [-Werror=unused-function]
       static void qcom_iommu_disable_clocks(struct qcom_iommu_dev *qcom_iommu)
      drivers/iommu/qcom_iommu.c:581:12: error: 'qcom_iommu_enable_clocks' defined but not used [-Werror=unused-function]
       static int qcom_iommu_enable_clocks(struct qcom_iommu_dev *qcom_iommu)
      
      Replacing that #ifdef with __maybe_unused annotations lets the compiler
      drop the functions silently instead.
      
      Fixes: 0ae349a0 ("iommu/qcom: Add qcom_iommu")
      Acked-by: NRob Clark <robdclark@gmail.com>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      6ce5b0f2
  6. 23 8月, 2017 1 次提交
  7. 22 8月, 2017 7 次提交
  8. 19 8月, 2017 2 次提交
  9. 18 8月, 2017 1 次提交
    • R
      iommu: Avoid NULL group dereference · 1464d0b1
      Robin Murphy 提交于
      The recently-removed FIXME in iommu_get_domain_for_dev() turns out to
      have been a little misleading, since that check is still worthwhile even
      when groups *are* universal. We have a few IOMMU-aware drivers which
      only care whether their device is already attached to an existing domain
      or not, for which the previous behaviour of iommu_get_domain_for_dev()
      was ideal, and who now crash if their device does not have an IOMMU.
      
      With IOMMU groups now serving as a reliable indicator of whether a
      device has an IOMMU or not (barring false-positives from VFIO no-IOMMU
      mode), drivers could arguably do this:
      
      	group = iommu_group_get(dev);
      	if (group) {
      		domain = iommu_get_domain_for_dev(dev);
      		iommu_group_put(group);
      	}
      
      However, rather than duplicate that code across multiple callsites,
      particularly when it's still only the domain they care about, let's skip
      straight to the next step and factor out the check into the common place
      it applies - in iommu_get_domain_for_dev() itself. Sure, it ends up
      looking rather familiar, but now it's backed by the reasoning of having
      a robust API able to do the expected thing for all devices regardless.
      
      Fixes: 05f80300 ("iommu: Finish making iommu_group support mandatory")
      Reported-by: NShawn Lin <shawn.lin@rock-chips.com>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      1464d0b1
  10. 17 8月, 2017 3 次提交