]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/amd: Introduce struct protection_domain.pd_mode
authorSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Mon, 5 Feb 2024 11:56:02 +0000 (11:56 +0000)
committerJoerg Roedel <jroedel@suse.de>
Fri, 9 Feb 2024 12:16:23 +0000 (13:16 +0100)
This enum variable is used to track the type of page table used by the
protection domain. It will replace the protection_domain.flags in
subsequent series.

Suggested-by: Jason Gunthorpe <jgg@ziepe.ca>
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20240205115615.6053-5-vasant.hegde@amd.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd/amd_iommu_types.h
drivers/iommu/amd/iommu.c

index fdf7807280bdc1e063a43ce34b53a013edeec65f..d29d4a321e5707d990db124123f7d1866b7f5623 100644 (file)
@@ -541,6 +541,11 @@ struct amd_io_pgtable {
        u64                     *pgd;           /* v2 pgtable pgd pointer */
 };
 
+enum protection_domain_mode {
+       PD_MODE_V1 = 1,
+       PD_MODE_V2,
+};
+
 /*
  * This structure contains generic data for  IOMMU protection domains
  * independent of their use.
@@ -556,6 +561,7 @@ struct protection_domain {
        int nid;                /* Node ID */
        u64 *gcr3_tbl;          /* Guest CR3 table */
        unsigned long flags;    /* flags to find out type of domain */
+       enum protection_domain_mode pd_mode; /* Track page table type */
        bool dirty_tracking;    /* dirty tracking is enabled in the domain */
        unsigned dev_cnt;       /* devices assigned to this domain */
        unsigned dev_iommu[MAX_IOMMUS]; /* per-IOMMU reference count */
index 2a5ae7a841cc7b7e33410cd0609185ec923c6125..a3c8f8ea926e2c5f29c6ca308b9fa1c47605ffa3 100644 (file)
@@ -2068,6 +2068,7 @@ static int protection_domain_init_v1(struct protection_domain *domain, int mode)
                        return -ENOMEM;
        }
 
+       domain->pd_mode = PD_MODE_V1;
        amd_iommu_domain_set_pgtable(domain, pt_root, mode);
 
        return 0;
@@ -2076,6 +2077,7 @@ static int protection_domain_init_v1(struct protection_domain *domain, int mode)
 static int protection_domain_init_v2(struct protection_domain *domain)
 {
        domain->flags |= PD_GIOV_MASK;
+       domain->pd_mode = PD_MODE_V2;
 
        domain->domain.pgsize_bitmap = AMD_IOMMU_PGSIZES_V2;