Commit c5395d5c authored by David Woodhouse's avatar David Woodhouse

intel-iommu: Clean up iommu_domain_identity_map()

Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 1a4a4551
...@@ -1861,31 +1861,25 @@ static int iommu_domain_identity_map(struct dmar_domain *domain, ...@@ -1861,31 +1861,25 @@ static int iommu_domain_identity_map(struct dmar_domain *domain,
unsigned long long start, unsigned long long start,
unsigned long long end) unsigned long long end)
{ {
unsigned long size; unsigned long first_vpfn = start >> VTD_PAGE_SHIFT;
unsigned long long base; unsigned long last_vpfn = end >> VTD_PAGE_SHIFT;
/* The address might not be aligned */ if (!reserve_iova(&domain->iovad, dma_to_mm_pfn(first_vpfn),
base = start & PAGE_MASK; dma_to_mm_pfn(last_vpfn))) {
size = end - base;
size = PAGE_ALIGN(size);
if (!reserve_iova(&domain->iovad, IOVA_PFN(base),
IOVA_PFN(base + size) - 1)) {
printk(KERN_ERR "IOMMU: reserve iova failed\n"); printk(KERN_ERR "IOMMU: reserve iova failed\n");
return -ENOMEM; return -ENOMEM;
} }
pr_debug("Mapping reserved region %lx@%llx for domain %d\n", pr_debug("Mapping reserved region %llx-%llx for domain %d\n",
size, base, domain->id); start, end, domain->id);
/* /*
* RMRR range might have overlap with physical memory range, * RMRR range might have overlap with physical memory range,
* clear it first * clear it first
*/ */
dma_pte_clear_range(domain, base >> VTD_PAGE_SHIFT, dma_pte_clear_range(domain, first_vpfn, last_vpfn);
(base + size - 1) >> VTD_PAGE_SHIFT);
return domain_pfn_mapping(domain, base >> VTD_PAGE_SHIFT, return domain_pfn_mapping(domain, first_vpfn, first_vpfn,
base >> VTD_PAGE_SHIFT, last_vpfn - first_vpfn + 1,
size >> VTD_PAGE_SHIFT,
DMA_PTE_READ|DMA_PTE_WRITE); DMA_PTE_READ|DMA_PTE_WRITE);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment