Patch "iommu/amd: Set page size bitmap during V2 domain allocation" has been added to the 6.3-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    iommu/amd: Set page size bitmap during V2 domain allocation

to the 6.3-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     iommu-amd-set-page-size-bitmap-during-v2-domain-allo.patch
and it can be found in the queue-6.3 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 5ccad5e1a3a57d97741cffe10b336f608a98cff2
Author: Jerry Snitselaar <jsnitsel@xxxxxxxxxx>
Date:   Tue Apr 4 00:27:42 2023 -0700

    iommu/amd: Set page size bitmap during V2 domain allocation
    
    [ Upstream commit 8f880d19e6ad645a4b8066d5ff091c980b3231e7 ]
    
    With the addition of the V2 page table support, the domain page size
    bitmap needs to be set prior to iommu core setting up direct mappings
    for reserved regions. When reserved regions are mapped, if this is not
    done, it will be looking at the V1 page size bitmap when determining
    the page size to use in iommu_pgsize(). When it gets into the actual
    amd mapping code, a check of see if the page size is supported can
    fail, because at that point it is checking it against the V2 page size
    bitmap which only supports 4K, 2M, and 1G.
    
    Add a check to __iommu_domain_alloc() to not override the
    bitmap if it was already set by the iommu ops domain_alloc() code path.
    
    Cc: Vasant Hegde <vasant.hegde@xxxxxxx>
    Cc: Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>
    Cc: Robin Murphy <robin.murphy@xxxxxxx>
    Cc: Will Deacon <will@xxxxxxxxxx>
    Cc: Joerg Roedel <joro@xxxxxxxxxx>
    Fixes: 4db6c41f0946 ("iommu/amd: Add support for using AMD IOMMU v2 page table for DMA-API")
    Signed-off-by: Jerry Snitselaar <jsnitsel@xxxxxxxxxx>
    Reviewed-by: Vasant Hegde <vasant.hegde@xxxxxxx>
    Link: https://lore.kernel.org/r/20230404072742.1895252-1-jsnitsel@xxxxxxxxxx
    Signed-off-by: Joerg Roedel <jroedel@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 5a505ba5467e1..167da5b1a5e31 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -1666,10 +1666,6 @@ static void do_attach(struct iommu_dev_data *dev_data,
 	domain->dev_iommu[iommu->index] += 1;
 	domain->dev_cnt                 += 1;
 
-	/* Override supported page sizes */
-	if (domain->flags & PD_GIOV_MASK)
-		domain->domain.pgsize_bitmap = AMD_IOMMU_PGSIZES_V2;
-
 	/* Update device table */
 	set_dte_entry(iommu, dev_data->devid, domain,
 		      ats, dev_data->iommu_v2);
@@ -2048,6 +2044,8 @@ static int protection_domain_init_v2(struct protection_domain *domain)
 
 	domain->flags |= PD_GIOV_MASK;
 
+	domain->domain.pgsize_bitmap = AMD_IOMMU_PGSIZES_V2;
+
 	if (domain_enable_v2(domain, 1)) {
 		domain_id_free(domain->id);
 		return -ENOMEM;
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 10db680acaed5..256a38371120e 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1964,8 +1964,13 @@ static struct iommu_domain *__iommu_domain_alloc(struct bus_type *bus,
 		return NULL;
 
 	domain->type = type;
-	/* Assume all sizes by default; the driver may override this later */
-	domain->pgsize_bitmap = bus->iommu_ops->pgsize_bitmap;
+	/*
+	 * If not already set, assume all sizes by default; the driver
+	 * may override this later
+	 */
+	if (!domain->pgsize_bitmap)
+		domain->pgsize_bitmap = bus->iommu_ops->pgsize_bitmap;
+
 	if (!domain->ops)
 		domain->ops = bus->iommu_ops->default_domain_ops;
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux