diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2008-12-02 19:05:50 (GMT) |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2009-01-03 13:11:56 (GMT) |
commit | 645c4c8d7289a718c9c828ec217f2b94e3b3e6ff (patch) | |
tree | 9f6e26175240dce2a9264f0acbce9ea26c216511 /arch/x86/kernel | |
parent | eb74ff6cc0080c7f6270fdfffba65c4eff23d3ad (diff) | |
download | linux-fsl-qoriq-645c4c8d7289a718c9c828ec217f2b94e3b3e6ff.tar.xz |
AMD IOMMU: add domain address lookup function for IOMMU API
Impact: add a generic function to lockup addresses in protection domains
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r-- | arch/x86/kernel/amd_iommu.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c index d8a0abf..b599e80 100644 --- a/arch/x86/kernel/amd_iommu.c +++ b/arch/x86/kernel/amd_iommu.c @@ -1788,4 +1788,35 @@ static void amd_iommu_unmap_range(struct iommu_domain *dom, iommu_flush_domain(domain->id); } +static phys_addr_t amd_iommu_iova_to_phys(struct iommu_domain *dom, + unsigned long iova) +{ + struct protection_domain *domain = dom->priv; + unsigned long offset = iova & ~PAGE_MASK; + phys_addr_t paddr; + u64 *pte; + + pte = &domain->pt_root[IOMMU_PTE_L2_INDEX(iova)]; + + if (!IOMMU_PTE_PRESENT(*pte)) + return 0; + + pte = IOMMU_PTE_PAGE(*pte); + pte = &pte[IOMMU_PTE_L1_INDEX(iova)]; + + if (!IOMMU_PTE_PRESENT(*pte)) + return 0; + + pte = IOMMU_PTE_PAGE(*pte); + pte = &pte[IOMMU_PTE_L0_INDEX(iova)]; + + if (!IOMMU_PTE_PRESENT(*pte)) + return 0; + + paddr = *pte & IOMMU_PAGE_MASK; + paddr |= offset; + + return paddr; +} + #endif |