Skip to content

Commit 77a1bce

Browse files
yonghyun-hwangjoergroedel
authored andcommitted
iommu/vt-d: Fix a bug in intel_iommu_iova_to_phys() for huge page
intel_iommu_iova_to_phys() has a bug when it translates an IOVA for a huge page onto its corresponding physical address. This commit fixes the bug by accomodating the level of page entry for the IOVA and adds IOVA's lower address to the physical address. Cc: <[email protected]> Acked-by: Lu Baolu <[email protected]> Reviewed-by: Moritz Fischer <[email protected]> Signed-off-by: Yonghyun Hwang <[email protected]> Fixes: 3871794 ("VT-d: Changes to support KVM") Signed-off-by: Joerg Roedel <[email protected]>
1 parent 02d715b commit 77a1bce

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/iommu/intel-iommu.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5700,8 +5700,10 @@ static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain,
57005700
u64 phys = 0;
57015701

57025702
pte = pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT, &level);
5703-
if (pte)
5704-
phys = dma_pte_addr(pte);
5703+
if (pte && dma_pte_present(pte))
5704+
phys = dma_pte_addr(pte) +
5705+
(iova & (BIT_MASK(level_to_offset_bits(level) +
5706+
VTD_PAGE_SHIFT) - 1));
57055707

57065708
return phys;
57075709
}

0 commit comments

Comments
 (0)