FAILED: patch "[PATCH] iommu/amd/pgtbl_v2: Fix domain max address" failed to apply to 6.1-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 11c439a19466e7feaccdbce148a75372fddaf4e9
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023060554-green-unshipped-c28a@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 11c439a19466e7feaccdbce148a75372fddaf4e9 Mon Sep 17 00:00:00 2001
From: Vasant Hegde <[email protected]>
Date: Thu, 18 May 2023 05:43:51 +0000
Subject: [PATCH] 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.
drivers/iommu/amd/iommu.c +10 -1
@@ -2129,6 +2129,15 @@ static struct protection_domain *protection_domain_alloc(unsigned int type)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) {struct protection_domain *domain;
@@ -2145,7 +2154,7 @@ static struct iommu_domain *amd_iommu_domain_alloc(unsigned type)return NULL ; 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;return &domain->domain;
Vasant Hegde
maintainerPATCH 1/1 iommu/amd/pgtbl_v2: Fix domain max address
[ Upstream commit 11c439a19466e7feaccdbce148a75372fddaf4e9 ]
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.
--- drivers/iommu/amd/iommu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/iommu/amd/iommu.c +10 -1
@@ -2094,6 +2094,15 @@ static struct protection_domain *protection_domain_alloc(unsigned int type)return NULL ; } +static inline u64 dma_max_address (void ) +{ +if (amd_iommu_pgtable ==AMD_IOMMU_V1 ) +return ~0ULL ; + +/* V2 with 4 level page table */ +return ((1ULL <<PM_LEVEL_SHIFT (PAGE_MODE_4_LEVEL )) -1 ); +} +static struct iommu_domain *amd_iommu_domain_alloc (unsigned type) {struct protection_domain *domain;
@@ -2110,7 +2119,7 @@ static struct iommu_domain *amd_iommu_domain_alloc(unsigned type)return NULL ; 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;return &domain->domain;
Signature · 1 line
2.31.1