Skip to content
  • Youquan Song's avatar
    intel-iommu: Enable super page (2MiB, 1GiB, etc.) support · 6dd9a7c7
    Youquan Song authored
    
    
    There are no externally-visible changes with this. In the loop in the
    internal __domain_mapping() function, we simply detect if we are mapping:
      - size >= 2MiB, and
      - virtual address aligned to 2MiB, and
      - physical address aligned to 2MiB, and
      - on hardware that supports superpages.
    
    (and likewise for larger superpages).
    
    We automatically use a superpage for such mappings. We never have to
    worry about *breaking* superpages, since we trust that we will always
    *unmap* the same range that was mapped. So all we need to do is ensure
    that dma_pte_clear_range() will also cope with superpages.
    
    Adjust pfn_to_dma_pte() to take a superpage 'level' as an argument, so
    it can return a PTE at the appropriate level rather than always
    extending the page tables all the way down to level 1. Again, this is
    simplified by the fact that we should never encounter existing small
    pages when we're creating a mapping; any old mapping that used the same
    virtual range will have been entirely removed and its obsolete page
    tables freed.
    
    Provide an 'intel_iommu=sp_off' argument on the command line as a
    chicken bit. Not that it should ever be required.
    
    ==
    
    The original commit seen in the iommu-2.6.git was Youquan's
    implementation (and completion) of my own half-baked code which I'd
    typed into an email. Followed by half a dozen subsequent 'fixes'.
    
    I've taken the unusual step of rewriting history and collapsing the
    original commits in order to keep the main history simpler, and make
    life easier for the people who are going to have to backport this to
    older kernels. And also so I can give it a more coherent commit comment
    which (hopefully) gives a better explanation of what's going on.
    
    The original sequence of commits leading to identical code was:
    
    Youquan Song (3):
          intel-iommu: super page support
          intel-iommu: Fix superpage alignment calculation error
          intel-iommu: Fix superpage level calculation error in dma_pfn_level_pte()
    
    David Woodhouse (4):
          intel-iommu: Precalculate superpage support for dmar_domain
          intel-iommu: Fix hardware_largepage_caps()
          intel-iommu: Fix inappropriate use of superpages in __domain_mapping()
          intel-iommu: Fix phys_pfn in __domain_mapping for sglist pages
    
    Signed-off-by: default avatarYouquan Song <youquan.song@intel.com>
    Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
    6dd9a7c7