iommu/amd/pgtbl_v2: Fix domain max address
IOMMU v2 page table supports 4 level (47 bit) or 5 level (56 bit) virtual
address space. Current code assumes it can support 64bit IOVA address
space. If IOVA allocator allocates virtual address > 47/56 bit (depending
on page table level) then it will do wrong mapping and cause invalid
translation.
Hence adjust aperture size to use max address supported by the page table.
Reported-by: Jerry Snitselaar <jsnitsel@redhat.com>
Fixes: aaac38f614 ("iommu/amd: Initial support for AMD IOMMU v2 page table")
Cc: <Stable@vger.kernel.org> # v6.0+
Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
Link: https://lore.kernel.org/r/20230518054351.9626-1-vasant.hegde@amd.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
pull/877/head
parent
2212fc2acf
commit
11c439a194
|
|
@ -2129,6 +2129,15 @@ out_err:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline u64 dma_max_address(void)
|
||||||
|
{
|
||||||
|
if (amd_iommu_pgtable == AMD_IOMMU_V1)
|
||||||
|
return ~0ULL;
|
||||||
|
|
||||||
|
/* V2 with 4/5 level page table */
|
||||||
|
return ((1ULL << PM_LEVEL_SHIFT(amd_iommu_gpt_level)) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
static struct iommu_domain *amd_iommu_domain_alloc(unsigned type)
|
static struct iommu_domain *amd_iommu_domain_alloc(unsigned type)
|
||||||
{
|
{
|
||||||
struct protection_domain *domain;
|
struct protection_domain *domain;
|
||||||
|
|
@ -2145,7 +2154,7 @@ static struct iommu_domain *amd_iommu_domain_alloc(unsigned type)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
domain->domain.geometry.aperture_start = 0;
|
domain->domain.geometry.aperture_start = 0;
|
||||||
domain->domain.geometry.aperture_end = ~0ULL;
|
domain->domain.geometry.aperture_end = dma_max_address();
|
||||||
domain->domain.geometry.force_aperture = true;
|
domain->domain.geometry.force_aperture = true;
|
||||||
|
|
||||||
return &domain->domain;
|
return &domain->domain;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue