1. 28 4月, 2022 3 次提交
  2. 28 2月, 2022 2 次提交
  3. 14 2月, 2022 1 次提交
    • L
      iommu/amd: Recover from event log overflow · 5ce97f4e
      Lennert Buytenhek 提交于
      The AMD IOMMU logs I/O page faults and such to a ring buffer in
      system memory, and this ring buffer can overflow.  The AMD IOMMU
      spec has the following to say about the interrupt status bit that
      signals this overflow condition:
      
      	EventOverflow: Event log overflow. RW1C. Reset 0b. 1 = IOMMU
      	event log overflow has occurred. This bit is set when a new
      	event is to be written to the event log and there is no usable
      	entry in the event log, causing the new event information to
      	be discarded. An interrupt is generated when EventOverflow = 1b
      	and MMIO Offset 0018h[EventIntEn] = 1b. No new event log
      	entries are written while this bit is set. Software Note: To
      	resume logging, clear EventOverflow (W1C), and write a 1 to
      	MMIO Offset 0018h[EventLogEn].
      
      The AMD IOMMU driver doesn't currently implement this recovery
      sequence, meaning that if a ring buffer overflow occurs, logging
      of EVT/PPR/GA events will cease entirely.
      
      This patch implements the spec-mandated reset sequence, with the
      minor tweak that the hardware seems to want to have a 0 written to
      MMIO Offset 0018h[EventLogEn] first, before writing an 1 into this
      field, or the IOMMU won't actually resume logging events.
      Signed-off-by: NLennert Buytenhek <buytenh@arista.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/YVrSXEdW2rzEfOvk@wantstofly.orgSigned-off-by: NJoerg Roedel <jroedel@suse.de>
      5ce97f4e
  4. 04 10月, 2021 1 次提交
  5. 29 9月, 2021 1 次提交
    • L
      iommu/amd: Use report_iommu_fault() · 9f78e446
      Lennert Buytenhek 提交于
      This patch makes iommu/amd call report_iommu_fault() when an I/O page
      fault occurs, which has two effects:
      
      1) It allows device drivers to register a callback to be notified of
         I/O page faults, via the iommu_set_fault_handler() API.
      
      2) It triggers the io_page_fault tracepoint in report_iommu_fault()
         when an I/O page fault occurs.
      
      The latter point is the main aim of this patch, as it allows
      rasdaemon-like daemons to be notified of I/O page faults, and to
      possibly initiate corrective action in response.
      
      A number of other IOMMU drivers already use report_iommu_fault(), and
      I/O page faults on those IOMMUs therefore already trigger this
      tracepoint -- but this isn't yet the case for AMD-Vi and Intel DMAR.
      
      The AMD IOMMU specification suggests that the bit in an I/O page fault
      event log entry that signals whether an I/O page fault was for a read
      request or for a write request is only meaningful when the faulting
      access was to a present page, but some testing on a Ryzen 3700X suggests
      that this bit encodes the correct value even for I/O page faults to
      non-present pages, and therefore, this patch passes the R/W information
      up the stack even for I/O page faults to non-present pages.
      Signed-off-by: NLennert Buytenhek <buytenh@arista.com>
      Link: https://lore.kernel.org/r/YVLyBW97vZLpOaAp@wantstofly.orgSigned-off-by: NJoerg Roedel <jroedel@suse.de>
      9f78e446
  6. 18 8月, 2021 2 次提交
  7. 02 8月, 2021 4 次提交
    • N
      iommu/amd: Use only natural aligned flushes in a VM · a270be1b
      Nadav Amit 提交于
      When running on an AMD vIOMMU, it is better to avoid TLB flushes
      of unmodified PTEs. vIOMMUs require the hypervisor to synchronize the
      virtualized IOMMU's PTEs with the physical ones. This process induce
      overheads.
      
      AMD IOMMU allows us to flush any range that is aligned to the power of
      2. So when running on top of a vIOMMU, break the range into sub-ranges
      that are naturally aligned, and flush each one separately. This apporach
      is better when running with a vIOMMU, but on physical IOMMUs, the
      penalty of IOTLB misses due to unnecessary flushed entries is likely to
      be low.
      
      Repurpose (i.e., keeping the name, changing the logic)
      domain_flush_pages() so it is used to choose whether to perform one
      flush of the whole range or multiple ones to avoid flushing unnecessary
      ranges. Use NpCache, as usual, to infer whether the IOMMU is physical or
      virtual.
      
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Jiajun Cao <caojiajun@vmware.com>
      Cc: Lu Baolu <baolu.lu@linux.intel.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-kernel@vger.kernel.org
      Suggested-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NNadav Amit <namit@vmware.com>
      Link: https://lore.kernel.org/r/20210723093209.714328-8-namit@vmware.comSigned-off-by: NJoerg Roedel <jroedel@suse.de>
      a270be1b
    • N
      iommu/amd: Sync once for scatter-gather operations · 3b122a56
      Nadav Amit 提交于
      On virtual machines, software must flush the IOTLB after each page table
      entry update.
      
      The iommu_map_sg() code iterates through the given scatter-gather list
      and invokes iommu_map() for each element in the scatter-gather list,
      which calls into the vendor IOMMU driver through iommu_ops callback. As
      the result, a single sg mapping may lead to multiple IOTLB flushes.
      
      Fix this by adding amd_iotlb_sync_map() callback and flushing at this
      point after all sg mappings we set.
      
      This commit is followed and inspired by commit 933fcd01
      ("iommu/vt-d: Add iotlb_sync_map callback").
      
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Jiajun Cao <caojiajun@vmware.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Lu Baolu <baolu.lu@linux.intel.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NNadav Amit <namit@vmware.com>
      Link: https://lore.kernel.org/r/20210723093209.714328-7-namit@vmware.comSigned-off-by: NJoerg Roedel <jroedel@suse.de>
      3b122a56
    • N
      iommu/amd: Tailored gather logic for AMD · fe6d269d
      Nadav Amit 提交于
      AMD's IOMMU can flush efficiently (i.e., in a single flush) any range.
      This is in contrast, for instnace, to Intel IOMMUs that have a limit on
      the number of pages that can be flushed in a single flush.  In addition,
      AMD's IOMMU do not care about the page-size, so changes of the page size
      do not need to trigger a TLB flush.
      
      So in most cases, a TLB flush due to disjoint range is not needed for
      AMD. Yet, vIOMMUs require the hypervisor to synchronize the virtualized
      IOMMU's PTEs with the physical ones. This process induce overheads, so
      it is better not to cause unnecessary flushes, i.e., flushes of PTEs
      that were not modified.
      
      Implement and use amd_iommu_iotlb_gather_add_page() and use it instead
      of the generic iommu_iotlb_gather_add_page(). Ignore disjoint regions
      unless "non-present cache" feature is reported by the IOMMU
      capabilities, as this is an indication we are running on a physical
      IOMMU. A similar indication is used by VT-d (see "caching mode"). The
      new logic retains the same flushing behavior that we had before the
      introduction of page-selective IOTLB flushes for AMD.
      
      On virtualized environments, check if the newly flushed region and the
      gathered one are disjoint and flush if it is.
      
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Jiajun Cao <caojiajun@vmware.com>
      Cc: Lu Baolu <baolu.lu@linux.intel.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-kernel@vger.kernel.org>
      Reviewed-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NNadav Amit <namit@vmware.com>
      Link: https://lore.kernel.org/r/20210723093209.714328-6-namit@vmware.comSigned-off-by: NJoerg Roedel <jroedel@suse.de>
      fe6d269d
    • N
      iommu/amd: Selective flush on unmap · fc65d0ac
      Nadav Amit 提交于
      Recent patch attempted to enable selective page flushes on AMD IOMMU but
      neglected to adapt amd_iommu_iotlb_sync() to use the selective flushes.
      
      Adapt amd_iommu_iotlb_sync() to use selective flushes and change
      amd_iommu_unmap() to collect the flushes. As a defensive measure, to
      avoid potential issues as those that the Intel IOMMU driver encountered
      recently, flush the page-walk caches by always setting the "pde"
      parameter. This can be removed later.
      
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Jiajun Cao <caojiajun@vmware.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Lu Baolu <baolu.lu@linux.intel.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NNadav Amit <namit@vmware.com>
      Link: https://lore.kernel.org/r/20210723093209.714328-2-namit@vmware.comSigned-off-by: NJoerg Roedel <jroedel@suse.de>
      fc65d0ac
  8. 26 7月, 2021 2 次提交
  9. 25 6月, 2021 1 次提交
  10. 07 6月, 2021 2 次提交
  11. 18 5月, 2021 2 次提交
  12. 15 4月, 2021 1 次提交
  13. 08 4月, 2021 1 次提交
    • N
      iommu/amd: Page-specific invalidations for more than one page · 268aa454
      Nadav Amit 提交于
      Currently, IOMMU invalidations and device-IOTLB invalidations using
      AMD IOMMU fall back to full address-space invalidation if more than a
      single page need to be flushed.
      
      Full flushes are especially inefficient when the IOMMU is virtualized by
      a hypervisor, since it requires the hypervisor to synchronize the entire
      address-space.
      
      AMD IOMMUs allow to provide a mask to perform page-specific
      invalidations for multiple pages that match the address. The mask is
      encoded as part of the address, and the first zero bit in the address
      (in bits [51:12]) indicates the mask size.
      
      Use this hardware feature to perform selective IOMMU and IOTLB flushes.
      Combine the logic between both for better code reuse.
      
      The IOMMU invalidations passed a smoke-test. The device IOTLB
      invalidations are untested.
      
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Jiajun Cao <caojiajun@vmware.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NNadav Amit <namit@vmware.com>
      Link: https://lore.kernel.org/r/20210323210619.513069-1-namit@vmware.comSigned-off-by: NJoerg Roedel <jroedel@suse.de>
      268aa454
  14. 07 4月, 2021 4 次提交
  15. 28 1月, 2021 11 次提交
  16. 27 1月, 2021 1 次提交
  17. 06 1月, 2021 1 次提交