1. 17 12月, 2015 3 次提交
  2. 23 9月, 2015 1 次提交
    • R
      iommu/io-pgtable-arm: Don't use dma_to_phys() · ffcb6d16
      Robin Murphy 提交于
      In checking whether DMA addresses differ from physical addresses, using
      dma_to_phys() is actually the wrong thing to do, since it may hide any
      DMA offset, which is precisely one of the things we are checking for.
      Simply casting between the two address types, whilst ugly, is in fact
      the appropriate course of action. Further care (and ugliness) is also
      necessary in the comparison to avoid truncation if phys_addr_t and
      dma_addr_t differ in size.
      
      We can also reject any device with a fixed DMA offset up-front at page
      table creation, leaving the allocation-time check for the more subtle
      cases like bounce buffering due to an incorrect DMA mask.
      
      Furthermore, we can then fix the hackish KConfig dependency so that
      architectures without a dma_to_phys() implementation may still
      COMPILE_TEST (or even use!) the code. The true dependency is on the
      DMA API, so use the appropriate symbol for that.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      [will: folded in selftest fix from Yong Wu]
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      ffcb6d16
  3. 18 8月, 2015 1 次提交
    • W
      iommu/io-pgtable-arm: Unmap and free table when overwriting with block · cf27ec93
      Will Deacon 提交于
      When installing a block mapping, we unconditionally overwrite a non-leaf
      PTE if we find one. However, this can cause a problem if the following
      sequence of events occur:
      
        (1) iommu_map called for a 4k (i.e. PAGE_SIZE) mapping at some address
            - We initialise the page table all the way down to a leaf entry
            - No TLB maintenance is required, because we're going from invalid
              to valid.
      
        (2) iommu_unmap is called on the mapping installed in (1)
            - We walk the page table to the final (leaf) entry and zero it
            - We only changed a valid leaf entry, so we invalidate leaf-only
      
        (3) iommu_map is called on the same address as (1), but this time for
            a 2MB (i.e. BLOCK_SIZE) mapping)
            - We walk the page table down to the penultimate level, where we
              find a table entry
            - We overwrite the table entry with a block mapping and return
              without any TLB maintenance and without freeing the memory used
              by the now-orphaned table.
      
      This last step can lead to a walk-cache caching the overwritten table
      entry, causing unexpected faults when the new mapping is accessed by a
      device. One way to fix this would be to collapse the page table when
      freeing the last page at a given level, but this would require expensive
      iteration on every map call. Instead, this patch detects the case when
      we are overwriting a table entry and explicitly unmaps the table first,
      which takes care of both freeing and TLB invalidation.
      
      Cc: <stable@vger.kernel.org>
      Reported-by: NBrian Starkey <brian.starkey@arm.com>
      Tested-by: NBrian Starkey <brian.starkey@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      cf27ec93
  4. 06 8月, 2015 3 次提交
    • R
      iommu/io-pgtable: Remove flush_pgtable callback · f5b83190
      Robin Murphy 提交于
      With the users fully converted to DMA API operations, it's dead, Jim.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      f5b83190
    • R
      iommu/io-pgtable-arm: Centralise sync points · 87a91b15
      Robin Murphy 提交于
      With all current users now opted in to DMA API operations, make the
      iommu_dev pointer mandatory, rendering the flush_pgtable callback
      redundant for cache maintenance. However, since the DMA calls could be
      nops in the case of a coherent IOMMU, we still need to ensure the page
      table updates are fully synchronised against a subsequent page table
      walk. In the unmap path, the TLB sync will usually need to do this
      anyway, so just cement that requirement; in the map path which may
      consist solely of cacheable memory writes (in the coherent case),
      insert an appropriate barrier at the end of the operation, and obviate
      the need to call flush_pgtable on every individual update for
      synchronisation.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      [will: slight clarification to tlb_sync comment]
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      87a91b15
    • R
      iommu/io-pgtable-arm: Allow appropriate DMA API use · f8d54961
      Robin Murphy 提交于
      Currently, users of the LPAE page table code are (ab)using dma_map_page()
      as a means to flush page table updates for non-coherent IOMMUs. Since
      from the CPU's point of view, creating IOMMU page tables *is* passing
      DMA buffers to a device (the IOMMU's page table walker), there's little
      reason not to use the DMA API correctly.
      
      Allow IOMMU drivers to opt into DMA API operations for page table
      allocation and updates by providing their appropriate device pointer.
      The expectation is that an LPAE IOMMU should have a full view of system
      memory, so use streaming mappings to avoid unnecessary pressure on
      ZONE_DMA, and treat any DMA translation as a warning sign.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      f8d54961
  5. 27 3月, 2015 1 次提交
    • W
      iommu/io-pgtable-arm: avoid speculative walks through TTBR1 · 63979b8d
      Will Deacon 提交于
      Although we set TCR.T1SZ to 0, the input address range covered by TTBR1
      is actually calculated using T0SZ in this case on the ARM SMMU. This
      could theoretically lead to speculative table walks through physical
      address zero, leading to all sorts of fun and games if we have MMIO
      regions down there.
      
      This patch avoids the issue by setting EPD1 to disable walks through
      the unused TTBR1 register.
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      63979b8d
  6. 25 2月, 2015 1 次提交
  7. 19 1月, 2015 3 次提交