diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2010-01-21 16:15:24 +0100 |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2010-03-07 18:01:12 +0100 |
commit | f03152bb7d0a74f409ad63ed36916444a7493d72 (patch) | |
tree | fe0f3593abe12e4476ac209ba4d8b87977bfdee3 /arch | |
parent | 24cd772315c19e4d9409d0d21367ec1ebab3149f (diff) | |
download | op-kernel-dev-f03152bb7d0a74f409ad63ed36916444a7493d72.zip op-kernel-dev-f03152bb7d0a74f409ad63ed36916444a7493d72.tar.gz |
x86/amd-iommu: Make amd_iommu_iova_to_phys aware of multiple page sizes
This patch extends the amd_iommu_iova_to_phys() function to
handle different page sizes correctly. It doesn't use
fetch_pte() anymore because we don't know (or care about)
the page_size used for mapping the given iova.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/amd_iommu.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c index 503d312..52e44af 100644 --- a/arch/x86/kernel/amd_iommu.c +++ b/arch/x86/kernel/amd_iommu.c @@ -2556,17 +2556,22 @@ 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; + unsigned long offset_mask; phys_addr_t paddr; - u64 *pte; + u64 *pte, __pte; pte = fetch_pte(domain, iova); if (!pte || !IOMMU_PTE_PRESENT(*pte)) return 0; - paddr = *pte & IOMMU_PAGE_MASK; - paddr |= offset; + if (PM_PTE_LEVEL(*pte) == 0) + offset_mask = PAGE_SIZE - 1; + else + offset_mask = PTE_PAGE_SIZE(*pte) - 1; + + __pte = *pte & PM_ADDR_MASK; + paddr = (__pte & ~offset_mask) | (iova & offset_mask); return paddr; } |