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>
This commit is contained in:
parent
24cd772315
commit
f03152bb7d
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue