1. 28 Jan, 2021 3 commits
    • Nadav Amit's avatar
      iommu/vt-d: Do not use flush-queue when caching-mode is on · 29b32839
      Nadav Amit authored
      When an Intel IOMMU is virtualized, and a physical device is
      passed-through to the VM, changes of the virtual IOMMU need to be
      propagated to the physical IOMMU. The hypervisor therefore needs to
      monitor PTE mappings in the IOMMU page-tables. Intel specifications
      provide "caching-mode" capability that a virtual IOMMU uses to report
      that the IOMMU is virtualized and a TLB flush is needed after mapping to
      allow the hypervisor to propagate virtual IOMMU mappings to the physical
      IOMMU. To the best of my knowledge no real physical IOMMU reports
      "caching-mode" as turned on.
      
      Synchronizing the virtual and the physical IOMMU tables is expensive if
      the hypervisor is unaware which PTEs have changed, as the hypervisor is
      required to walk all the virtualized tables and look for changes.
      Consequently, domain flushes are much more expensive than page-specific
      flushes on virtualized IOMMUs with passthrough devices. The kernel
      therefore exploited the "caching-mode" indication to avoid domain
      flushing and use page-specific flushing in virtualized environments. See
      commit 78d5f0f5 ("intel-iommu: Avoid global flushes with caching
      mode.")
      
      This behavior changed after commit 13cf0174 ("iommu/vt-d: Make use
      of iova deferred flushing"). Now, when batched TLB flushing is used (the
      default), full TLB domain flushes are performed frequently, requiring
      the hypervisor to perform expensive synchronization between the virtual
      TLB and the physical one.
      
      Getting batched TLB flushes to use page-specific invalidations again in
      such circumstances is not easy, since the TLB invalidation scheme
      assumes that "full" domain TLB flushes are performed for scalability.
      
      Disable batched TLB flushes when caching-mode is on, as the performance
      benefit from using batched TLB invalidations is likely to be much
      smaller than the overhead of the virtual-to-physical IOMMU page-tables
      synchronization.
      
      Fixes: 13cf0174 ("iommu/vt-d: Make use of iova deferred flushing")
      Signed-off-by: default avatarNadav Amit <namit@vmware.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Lu Baolu <baolu.lu@linux.intel.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: stable@vger.kernel.org
      Acked-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
      Link: https://lore.kernel.org/r/20210127175317.1600473-1-namit@vmware.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      29b32839
    • Lu Baolu's avatar
      iommu/vt-d: Correctly check addr alignment in qi_flush_dev_iotlb_pasid() · 494b3688
      Lu Baolu authored
      An incorrect address mask is being used in the qi_flush_dev_iotlb_pasid()
      to check the address alignment. This leads to a lot of spurious kernel
      warnings:
      
      [  485.837093] DMAR: Invalidate non-aligned address 7f76f47f9000, order 0
      [  485.837098] DMAR: Invalidate non-aligned address 7f76f47f9000, order 0
      [  492.494145] qi_flush_dev_iotlb_pasid: 5734 callbacks suppressed
      [  492.494147] DMAR: Invalidate non-aligned address 7f7728800000, order 11
      [  492.508965] DMAR: Invalidate non-aligned address 7f7728800000, order 11
      
      Fix it by checking the alignment in right way.
      
      Fixes: 288d08e7 ("iommu/vt-d: Handle non-page aligned address")
      Reported-and-tested-by: default avatarGuo Kaijie <Kaijie.Guo@intel.com>
      Signed-off-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
      Cc: Liu Yi L <yi.l.liu@intel.com>
      Link: https://lore.kernel.org/r/20210119043500.1539596-1-baolu.lu@linux.intel.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      494b3688
    • Suravee Suthikulpanit's avatar
      iommu/amd: Use IVHD EFR for early initialization of IOMMU features · a44092e3
      Suravee Suthikulpanit authored
      IOMMU Extended Feature Register (EFR) is used to communicate
      the supported features for each IOMMU to the IOMMU driver.
      This is normally read from the PCI MMIO register offset 0x30,
      and used by the iommu_feature() helper function.
      
      However, there are certain scenarios where the information is needed
      prior to PCI initialization, and the iommu_feature() function is used
      prematurely w/o warning. This has caused incorrect initialization of IOMMU.
      This is the case for the commit 6d39bdee ("iommu/amd: Enforce 4k
      mapping for certain IOMMU data structures")
      
      Since, the EFR is also available in the IVHD header, and is available to
      the driver prior to PCI initialization. Therefore, default to using
      the IVHD EFR instead.
      
      Fixes: 6d39bdee ("iommu/amd: Enforce 4k mapping for certain IOMMU data structures")
      Signed-off-by: default avatarSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
      Tested-by: default avatarBrijesh Singh <brijesh.singh@amd.com>
      Reviewed-by: default avatarRobert Richter <rrichter@amd.com>
      Link: https://lore.kernel.org/r/20210120135002.2682-1-suravee.suthikulpanit@amd.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      a44092e3
  2. 25 Jan, 2021 1 commit
  3. 24 Jan, 2021 36 commits