diff options
-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 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 | } |