1. 31 3月, 2015 1 次提交
  2. 25 3月, 2015 2 次提交
    • D
      iommu/vt-d: support extended root and context entries · 03ecc32c
      David Woodhouse 提交于
      Add a new function iommu_context_addr() which takes care of the
      differences and returns a pointer to a context entry which may be
      in either format. The formats are binary compatible for all the old
      fields anyway; the new one is just larger and some of the reserved
      bits in the original 128 are now meaningful.
      
      So far, nothing actually uses the new fields in the extended context
      entry. Modulo hardware bugs with interpreting the new-style tables,
      this should basically be a no-op.
      Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      03ecc32c
    • D
      iommu/vt-d: Allow RMRR on graphics devices too · 18436afd
      David Woodhouse 提交于
      Commit c875d2c1 ("iommu/vt-d: Exclude devices using RMRRs from IOMMU API
      domains") prevents certain options for devices with RMRRs. This even
      prevents those devices from getting a 1:1 mapping with 'iommu=pt',
      because we don't have the code to handle *preserving* the RMRR regions
      when moving the device between domains.
      
      There's already an exclusion for USB devices, because we know the only
      reason for RMRRs there is a misguided desire to keep legacy
      keyboard/mouse emulation running in some theoretical OS which doesn't
      have support for USB in its own right... but which *does* enable the
      IOMMU.
      
      Add an exclusion for graphics devices too, so that 'iommu=pt' works
      there. We should be able to successfully assign graphics devices to
      guests too, as long as the initial handling of stolen memory is
      reconfigured appropriately. This has certainly worked in the past.
      Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      Cc: stable@vger.kernel.org
      18436afd
  3. 24 3月, 2015 1 次提交
  4. 23 3月, 2015 1 次提交
    • A
      iommu/vt-d: Detach domain *only* from attached iommus · 71684406
      Alex Williamson 提交于
      Device domains never span IOMMU hardware units, which allows the
      domain ID space for each IOMMU to be an independent address space.
      Therefore we can have multiple, independent domains, each with the
      same domain->id, but attached to different hardware units.  This is
      also why we need to do a heavy-weight search for VM domains since
      they can span multiple IOMMUs hardware units and we don't require a
      single global ID to use for all hardware units.
      
      Therefore, if we call iommu_detach_domain() across all active IOMMU
      hardware units for a non-VM domain, the result is that we clear domain
      IDs that are not associated with our domain, allowing them to be
      re-allocated and causing apparent coherency issues when the device
      cannot access IOVAs for the intended domain.
      
      This bug was introduced in commit fb170fb4 ("iommu/vt-d: Introduce
      helper functions to make code symmetric for readability"), but is
      significantly exacerbated by the more recent commit 62c22167
      ("iommu/vt-d: Fix dmar_domain leak in iommu_attach_device") which calls
      domain_exit() more frequently to resolve a domain leak.
      
      Fixes: fb170fb4 ("iommu/vt-d: Introduce helper functions to make code symmetric for readability")
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Cc: Jiang Liu <jiang.liu@linux.intel.com>
      Cc: stable@vger.kernel.org # v3.17+
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      71684406
  5. 17 3月, 2015 1 次提交
    • R
      ACPI: Introduce has_acpi_companion() · ca5b74d2
      Rafael J. Wysocki 提交于
      Now that the ACPI companions of devices are represented by pointers
      to struct fwnode_handle, it is not quite efficient to check whether
      or not an ACPI companion of a device is present by evaluating the
      ACPI_COMPANION() macro.
      
      For this reason, introduce a special static inline routine for that,
      has_acpi_companion(), and update the code to use it where applicable.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      ca5b74d2
  6. 03 3月, 2015 1 次提交
    • Q
      iommu/vt-d: Convert non-returned local variable to boolean when relevant · 2f119c78
      Quentin Lambert 提交于
      This patch was produced using Coccinelle. A simplified version of the
      semantic patch is:
      
      @r exists@
      identifier f;
      local idexpression u8 x;
      identifier xname;
      @@
      
      f(...) {
      ...when any
      (
        x@xname = 1;
      |
        x@xname = 0;
      )
      ...when any
      }
      
      @bad exists@
      identifier r.f;
      local idexpression u8 r.x
      expression e1 != {0, 1}, e2;
      @@
      
      f(...) {
      ...when any
      (
        x = e1;
      |
        x + e2
      )
      ...when any
      }
      
      @depends on !bad@
      identifier r.f;
      local idexpression u8 r.x;
      identifier r.xname;
      @@
      
      f(...) {
      ...
      ++ bool xname;
      - int xname;
      <...
      (
        x =
      - 1
      + true
      |
        x =
      - -1
      + false
      )
      ...>
      
      }
      Signed-off-by: NQuentin Lambert <lambert.quentin@gmail.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      2f119c78
  7. 19 1月, 2015 3 次提交
  8. 05 1月, 2015 2 次提交
  9. 02 12月, 2014 1 次提交
  10. 18 11月, 2014 4 次提交
  11. 06 11月, 2014 1 次提交
    • L
      x86/vt-d: Fix incorrect bit operations in setting values · 1a2262f9
      Li, Zhen-Hua 提交于
      The function context_set_address_root() and set_root_value are setting new
      address in a wrong way, and this patch is trying to fix this problem.
      
      According to Intel Vt-d specs(Feb 2011, Revision 1.3), Chapter 9.1 and 9.2,
      field ctp in root entry is using bits 12:63, field asr in context entry is
      using bits 12:63.
      
      To set these fields, the following functions are used:
      static inline void context_set_address_root(struct context_entry *context,
              unsigned long value);
      and
      static inline void set_root_value(struct root_entry *root, unsigned long value)
      
      But they are using an invalid method to set these fields, in current code, only
      a '|' operator is used to set it. This will not set the asr to the expected
      value if it has an old value.
      
      For example:
      Before calling this function,
      	context->lo = 0x3456789012111;
      	value = 0x123456789abcef12;
      
      After we call context_set_address_root(context, value), expected result is
      	context->lo == 0x123456789abce111;
      
      But the actual result is:
      	context->lo == 0x1237577f9bbde111;
      
      So we need to clear bits 12:63 before setting the new value, this will fix
      this problem.
      Signed-off-by: NLi, Zhen-Hua <zhen-hual@hp.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      1a2262f9
  12. 04 11月, 2014 1 次提交
    • O
      iommu: Add iommu_map_sg() function · 315786eb
      Olav Haugan 提交于
      Mapping and unmapping are more often than not in the critical path.
      map_sg allows IOMMU driver implementations to optimize the process
      of mapping buffers into the IOMMU page tables.
      
      Instead of mapping a buffer one page at a time and requiring potentially
      expensive TLB operations for each page, this function allows the driver
      to map all pages in one go and defer TLB maintenance until after all
      pages have been mapped.
      
      Additionally, the mapping operation would be faster in general since
      clients does not have to keep calling map API over and over again for
      each physically contiguous chunk of memory that needs to be mapped to a
      virtually contiguous region.
      Signed-off-by: NOlav Haugan <ohaugan@codeaurora.org>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      315786eb
  13. 02 10月, 2014 1 次提交
  14. 25 9月, 2014 1 次提交
  15. 18 8月, 2014 1 次提交
    • J
      iommu/vt-d: Defer domain removal if device is assigned to a driver · e7f9fa54
      Joerg Roedel 提交于
      When the BUS_NOTIFY_DEL_DEVICE event is received the device
      might still be attached to a driver. In this case the domain
      can't be released as the mappings might still be in use.
      
      Defer the domain removal in this case until we receivce the
      BUS_NOTIFY_UNBOUND_DRIVER event.
      
      Cc: Jiang Liu <jiang.liu@linux.intel.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: stable@vger.kernel.org   # v3.15, v3.16
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      e7f9fa54
  16. 29 7月, 2014 1 次提交
  17. 23 7月, 2014 12 次提交
  18. 07 7月, 2014 1 次提交
  19. 04 7月, 2014 4 次提交
    • A
      iommu/vt-d: Make use of IOMMU sysfs support · a5459cfe
      Alex Williamson 提交于
      Register our DRHD IOMMUs, cross link devices, and provide a base set
      of attributes for the IOMMU.  Note that IRQ remapping support parses
      the DMAR table very early in boot, well before the iommu_class can
      reasonably be setup, so our registration is split between
      intel_iommu_init(), which occurs later, and alloc_iommu(), which
      typically occurs much earlier, but may happen at any time later
      with IOMMU hot-add support.
      
      On a typical desktop system, this provides the following (pruned):
      
      $ find /sys | grep dmar
      /sys/devices/virtual/iommu/dmar0
      /sys/devices/virtual/iommu/dmar0/devices
      /sys/devices/virtual/iommu/dmar0/devices/0000:00:02.0
      /sys/devices/virtual/iommu/dmar0/intel-iommu
      /sys/devices/virtual/iommu/dmar0/intel-iommu/cap
      /sys/devices/virtual/iommu/dmar0/intel-iommu/ecap
      /sys/devices/virtual/iommu/dmar0/intel-iommu/address
      /sys/devices/virtual/iommu/dmar0/intel-iommu/version
      /sys/devices/virtual/iommu/dmar1
      /sys/devices/virtual/iommu/dmar1/devices
      /sys/devices/virtual/iommu/dmar1/devices/0000:00:00.0
      /sys/devices/virtual/iommu/dmar1/devices/0000:00:01.0
      /sys/devices/virtual/iommu/dmar1/devices/0000:00:16.0
      /sys/devices/virtual/iommu/dmar1/devices/0000:00:1a.0
      /sys/devices/virtual/iommu/dmar1/devices/0000:00:1b.0
      /sys/devices/virtual/iommu/dmar1/devices/0000:00:1c.0
      ...
      /sys/devices/virtual/iommu/dmar1/intel-iommu
      /sys/devices/virtual/iommu/dmar1/intel-iommu/cap
      /sys/devices/virtual/iommu/dmar1/intel-iommu/ecap
      /sys/devices/virtual/iommu/dmar1/intel-iommu/address
      /sys/devices/virtual/iommu/dmar1/intel-iommu/version
      /sys/class/iommu/dmar0
      /sys/class/iommu/dmar1
      
      (devices also link back to the dmar units)
      
      This makes address, version, capabilities, and extended capabilities
      available, just like printed on boot.  I've tried not to duplicate
      data that can be found in the DMAR table, with the exception of the
      address, which provides an easy way to associate the sysfs device with
      a DRHD entry in the DMAR.  It's tempting to add scopes and RMRR data
      here, but the full DMAR table is already exposed under /sys/firmware/
      and therefore already provides a way for userspace to learn such
      details.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      a5459cfe
    • A
      iommu/vt-d: Update to use PCI DMA aliases · 579305f7
      Alex Williamson 提交于
      VT-d code currently makes use of pci_find_upstream_pcie_bridge() in
      order to find the topology based alias of a device.  This function has
      a few problems.  First, it doesn't check the entire alias path of the
      device to the root bus, therefore if a PCIe device is masked upstream,
      the wrong result is produced.  Also, it's known to get confused and
      give up when it crosses a bridge from a conventional PCI bus to a PCIe
      bus that lacks a PCIe capability.  The PCI-core provided DMA alias
      support solves both of these problems and additionally adds support
      for DMA function quirks allowing VT-d to work with devices like
      Marvell and Ricoh with known broken requester IDs.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      579305f7
    • A
      iommu/vt-d: Use iommu_group_get_for_dev() · e17f9ff4
      Alex Williamson 提交于
      The IOMMU code now provides a common interface for finding or
      creating an IOMMU group for a device on PCI buses.  Make use of it
      and remove piles of code.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      e17f9ff4
    • Y
      iommu/vt-d: Suppress compiler warnings · aa4d066a
      Yijing Wang 提交于
      suppress compiler warnings:
      drivers/iommu/intel-iommu.c: In function ‘device_to_iommu’:
      drivers/iommu/intel-iommu.c:673: warning: ‘segment’ may be used uninitialized in this function
      drivers/iommu/intel-iommu.c: In function ‘get_domain_for_dev.clone.3’:
      drivers/iommu/intel-iommu.c:2217: warning: ‘bridge_bus’ may be used uninitialized in this function
      drivers/iommu/intel-iommu.c:2217: warning: ‘bridge_devfn’ may be used uninitialized in this function
      Signed-off-by: NYijing Wang <wangyijing@huawei.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      aa4d066a