diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/amd_iommu.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c index 2f7c0b3a448b..1fcedbe39a99 100644 --- a/arch/x86/kernel/amd_iommu.c +++ b/arch/x86/kernel/amd_iommu.c | |||
@@ -1718,4 +1718,33 @@ static int amd_iommu_attach_device(struct iommu_domain *dom, | |||
1718 | return 0; | 1718 | return 0; |
1719 | } | 1719 | } |
1720 | 1720 | ||
1721 | static int amd_iommu_map_range(struct iommu_domain *dom, | ||
1722 | unsigned long iova, phys_addr_t paddr, | ||
1723 | size_t size, int iommu_prot) | ||
1724 | { | ||
1725 | struct protection_domain *domain = dom->priv; | ||
1726 | unsigned long i, npages = iommu_num_pages(paddr, size, PAGE_SIZE); | ||
1727 | int prot = 0; | ||
1728 | int ret; | ||
1729 | |||
1730 | if (iommu_prot & IOMMU_READ) | ||
1731 | prot |= IOMMU_PROT_IR; | ||
1732 | if (iommu_prot & IOMMU_WRITE) | ||
1733 | prot |= IOMMU_PROT_IW; | ||
1734 | |||
1735 | iova &= PAGE_MASK; | ||
1736 | paddr &= PAGE_MASK; | ||
1737 | |||
1738 | for (i = 0; i < npages; ++i) { | ||
1739 | ret = iommu_map_page(domain, iova, paddr, prot); | ||
1740 | if (ret) | ||
1741 | return ret; | ||
1742 | |||
1743 | iova += PAGE_SIZE; | ||
1744 | paddr += PAGE_SIZE; | ||
1745 | } | ||
1746 | |||
1747 | return 0; | ||
1748 | } | ||
1749 | |||
1721 | #endif | 1750 | #endif |