aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/amd_iommu.c
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2010-01-21 10:15:24 -0500
committerJoerg Roedel <joerg.roedel@amd.com>2010-03-07 12:01:12 -0500
commitf03152bb7d0a74f409ad63ed36916444a7493d72 (patch)
treefe0f3593abe12e4476ac209ba4d8b87977bfdee3 /arch/x86/kernel/amd_iommu.c
parent24cd772315c19e4d9409d0d21367ec1ebab3149f (diff)
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/x86/kernel/amd_iommu.c')
-rw-r--r--arch/x86/kernel/amd_iommu.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 503d312f9d6f..52e44af15705 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,
2556 unsigned long iova) 2556 unsigned long iova)
2557{ 2557{
2558 struct protection_domain *domain = dom->priv; 2558 struct protection_domain *domain = dom->priv;
2559 unsigned long offset = iova & ~PAGE_MASK; 2559 unsigned long offset_mask;
2560 phys_addr_t paddr; 2560 phys_addr_t paddr;
2561 u64 *pte; 2561 u64 *pte, __pte;
2562 2562
2563 pte = fetch_pte(domain, iova); 2563 pte = fetch_pte(domain, iova);
2564 2564
2565 if (!pte || !IOMMU_PTE_PRESENT(*pte)) 2565 if (!pte || !IOMMU_PTE_PRESENT(*pte))
2566 return 0; 2566 return 0;
2567 2567
2568 paddr = *pte & IOMMU_PAGE_MASK; 2568 if (PM_PTE_LEVEL(*pte) == 0)
2569 paddr |= offset; 2569 offset_mask = PAGE_SIZE - 1;
2570 else
2571 offset_mask = PTE_PAGE_SIZE(*pte) - 1;
2572
2573 __pte = *pte & PM_ADDR_MASK;
2574 paddr = (__pte & ~offset_mask) | (iova & offset_mask);
2570 2575
2571 return paddr; 2576 return paddr;
2572} 2577}