1. 08 8月, 2018 1 次提交
  2. 06 7月, 2018 1 次提交
    • G
      iommu: Enable debugfs exposure of IOMMU driver internals · bad614b2
      Gary R Hook 提交于
      Provide base enablement for using debugfs to expose internal data of an
      IOMMU driver. When called, create the /sys/kernel/debug/iommu directory.
      
      Emit a strong warning at boot time to indicate that this feature is
      enabled.
      
      This function is called from iommu_init, and creates the initial DebugFS
      directory. Drivers may then call iommu_debugfs_new_driver_dir() to
      instantiate a device-specific directory to expose internal data.
      It will return a pointer to the new dentry structure created in
      /sys/kernel/debug/iommu, or NULL in the event of a failure.
      
      Since the IOMMU driver can not be removed from the running system, there
      is no need for an "off" function.
      Signed-off-by: NGary R Hook <gary.hook@amd.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      bad614b2
  3. 14 2月, 2018 1 次提交
  4. 27 9月, 2017 1 次提交
  5. 31 8月, 2017 1 次提交
    • 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
  6. 16 8月, 2017 1 次提交
  7. 15 8月, 2017 1 次提交
    • J
      iommu: Fix wrong freeing of iommu_device->dev · 2926a2aa
      Joerg Roedel 提交于
      The struct iommu_device has a 'struct device' embedded into
      it, not as a pointer, but the whole struct. In the
      conversion of the iommu drivers to use struct iommu_device
      it was forgotten that the relase function for that struct
      device simply calls kfree() on the pointer.
      
      This frees memory that was never allocated and causes memory
      corruption.
      
      To fix this issue, use a pointer to struct device instead of
      embedding the whole struct. This needs some updates in the
      iommu sysfs code as well as the Intel VT-d and AMD IOMMU
      driver.
      Reported-by: NSebastian Ott <sebott@linux.vnet.ibm.com>
      Fixes: 39ab9555 ('iommu: Add sysfs bindings for struct iommu_device')
      Cc: stable@vger.kernel.org # >= v4.11
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      2926a2aa
  8. 26 7月, 2017 1 次提交
  9. 29 4月, 2017 1 次提交
  10. 27 4月, 2017 2 次提交
  11. 06 4月, 2017 1 次提交
  12. 22 3月, 2017 1 次提交
    • R
      iommu: Disambiguate MSI region types · 9d3a4de4
      Robin Murphy 提交于
      The introduction of reserved regions has left a couple of rough edges
      which we could do with sorting out sooner rather than later. Since we
      are not yet addressing the potential dynamic aspect of software-managed
      reservations and presenting them at arbitrary fixed addresses, it is
      incongruous that we end up displaying hardware vs. software-managed MSI
      regions to userspace differently, especially since ARM-based systems may
      actually require one or the other, or even potentially both at once,
      (which iommu-dma currently has no hope of dealing with at all). Let's
      resolve the former user-visible inconsistency ASAP before the ABI has
      been baked into a kernel release, in a way that also lays the groundwork
      for the latter shortcoming to be addressed by follow-up patches.
      
      For clarity, rename the software-managed type to IOMMU_RESV_SW_MSI, use
      IOMMU_RESV_MSI to describe the hardware type, and document everything a
      little bit. Since the x86 MSI remapping hardware falls squarely under
      this meaning of IOMMU_RESV_MSI, apply that type to their regions as well,
      so that we tell the same story to userspace across all platforms.
      
      Secondly, as the various region types require quite different handling,
      and it really makes little sense to ever try combining them, convert the
      bitfield-esque #defines to a plain enum in the process before anyone
      gets the wrong impression.
      
      Fixes: d30ddcaa ("iommu: Add a new type field in iommu_resv_region")
      Reviewed-by: NEric Auger <eric.auger@redhat.com>
      CC: Alex Williamson <alex.williamson@redhat.com>
      CC: David Woodhouse <dwmw2@infradead.org>
      CC: kvm@vger.kernel.org
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      9d3a4de4
  13. 10 2月, 2017 6 次提交
  14. 23 1月, 2017 4 次提交
  15. 19 1月, 2017 1 次提交
  16. 29 11月, 2016 1 次提交
    • L
      iommu: Make of_iommu_set/get_ops() DT agnostic · e4f10ffe
      Lorenzo Pieralisi 提交于
      The of_iommu_{set/get}_ops() API is used to associate a device
      tree node with a specific set of IOMMU operations. The same
      kernel interface is required on systems booting with ACPI, where
      devices are not associated with a device tree node, therefore
      the interface requires generalization.
      
      The struct device fwnode member represents the fwnode token associated
      with the device and the struct it points at is firmware specific;
      regardless, it is initialized on both ACPI and DT systems and makes an
      ideal candidate to use it to associate a set of IOMMU operations to a
      given device, through its struct device.fwnode member pointer, paving
      the way for representing per-device iommu_ops (ie an iommu instance
      associated with a device).
      
      Convert the DT specific of_iommu_{set/get}_ops() interface to
      use struct device.fwnode as a look-up token, making the interface
      usable on ACPI systems and rename the data structures and the
      registration API so that they are made to represent their usage
      more clearly.
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Reviewed-by: NRobin Murphy <robin.murphy@arm.com>
      Reviewed-by: NTomasz Nowicki <tn@semihalf.com>
      Tested-by: NHanjun Guo <hanjun.guo@linaro.org>
      Tested-by: NTomasz Nowicki <tn@semihalf.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Hanjun Guo <hanjun.guo@linaro.org>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      e4f10ffe
  17. 15 11月, 2016 1 次提交
  18. 16 9月, 2016 1 次提交
    • R
      iommu: Introduce iommu_fwspec · 57f98d2f
      Robin Murphy 提交于
      Introduce a common structure to hold the per-device firmware data that
      most IOMMU drivers need to keep track of. This enables us to configure
      much of that data from common firmware code, and consolidate a lot of
      the equivalent implementations, device look-up tables, etc. which are
      currently strewn across IOMMU drivers.
      
      This will also be enable us to address the outstanding "multiple IOMMUs
      on the platform bus" problem by tweaking IOMMU API calls to prefer
      dev->fwspec->ops before falling back to dev->bus->iommu_ops, and thus
      gracefully handle those troublesome systems which we currently cannot.
      
      As the first user, hook up the OF IOMMU configuration mechanism. The
      driver-defined nature of DT cells means that we still need the drivers
      to translate and add the IDs themselves, but future users such as the
      much less free-form ACPI IORT will be much simpler and self-contained.
      
      CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Suggested-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      57f98d2f
  19. 13 7月, 2016 1 次提交
  20. 09 5月, 2016 2 次提交
  21. 07 4月, 2016 1 次提交
  22. 05 4月, 2016 1 次提交
    • A
      iommu: provide of_xlate pointer unconditionally · b70bb984
      Arnd Bergmann 提交于
      iommu drivers that support the standard DT bindings use a of_xlate
      callback pointer, but that is only part of struct iommu_ops when
      CONFIG_OF_IOMMU is enabled, leading to build errors in randconfig
      builds when that is not provided:
      
      drivers/iommu/mtk_iommu.c:497:2: error: unknown field 'of_xlate' specified in initializer
        .of_xlate = mtk_iommu_of_xlate,
        ^
      drivers/iommu/mtk_iommu.c:497:14: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
        .of_xlate = mtk_iommu_of_xlate,
                    ^~~~~~~~~~~~~~~~~~
      drivers/iommu/mtk_iommu.c:497:14: note: (near initialization for 'mtk_iommu_ops.domain_get_attr')
      
      We can work around it by adding more #ifdefs in each driver, but
      it seems nicer to just allow setting the pointer even if it is
      unused. This makes the driver code look nicer, and it gives better
      compile-time coverage when test building on other architectures.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Fixes: 0df4fabe ("iommu/mediatek: Add mt8173 IOMMU driver")
      Reviewed-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      b70bb984
  23. 29 1月, 2016 1 次提交
  24. 22 10月, 2015 3 次提交
  25. 15 10月, 2015 1 次提交
    • R
      iommu: Implement common IOMMU ops for DMA mapping · 0db2e5d1
      Robin Murphy 提交于
      Taking inspiration from the existing arch/arm code, break out some
      generic functions to interface the DMA-API to the IOMMU-API. This will
      do the bulk of the heavy lifting for IOMMU-backed dma-mapping.
      
      Since associating an IOVA allocator with an IOMMU domain is a fairly
      common need, rather than introduce yet another private structure just to
      do this for ourselves, extend the top-level struct iommu_domain with the
      notion. A simple opaque cookie allows reuse by other IOMMU API users
      with their various different incompatible allocator types.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      0db2e5d1
  26. 18 7月, 2015 1 次提交
    • N
      include, lib: add __printf attributes to several function prototypes · 8db14860
      Nicolas Iooss 提交于
      Using __printf attributes helps to detect several format string issues
      at compile time (even though -Wformat-security is currently disabled in
      Makefile).  For example it can detect when formatting a pointer as a
      number, like the issue fixed in commit a3fa71c4 ("wl18xx: show
      rx_frames_per_rates as an array as it really is"), or when the arguments
      do not match the format string, c.f.  for example commit 5ce1aca8
      ("reiserfs: fix __RASSERT format string").
      
      To prevent similar bugs in the future, add a __printf attribute to every
      function prototype which needs one in include/linux/ and lib/.  These
      functions were mostly found by using gcc's -Wsuggest-attribute=format
      flag.
      Signed-off-by: NNicolas Iooss <nicolas.iooss_linux@m4x.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Felipe Balbi <balbi@ti.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8db14860
  27. 11 6月, 2015 1 次提交
  28. 09 6月, 2015 1 次提交