]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/amd: Introduce struct amd_iommu_viommu
authorSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Thu, 15 Jan 2026 06:08:09 +0000 (06:08 +0000)
committerJoerg Roedel <joerg.roedel@amd.com>
Sun, 18 Jan 2026 09:56:12 +0000 (10:56 +0100)
Which stores reference to nested parent domain assigned during the call to
struct iommu_ops.viommu_init(). Information in the nest parent is needed
when setting up the nested translation.

Note that the viommu initialization will be introduced in subsequent
commit.

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
drivers/iommu/amd/amd_iommu_types.h
drivers/iommu/amd/iommu.c
drivers/iommu/amd/iommufd.c
drivers/iommu/amd/iommufd.h

index d8753841cd1f6fa2898e06d7b823629d05b3471a..d5b3393ab3a91425e5b289bcf871bfdb8fe3c922 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/list.h>
 #include <linux/spinlock.h>
 #include <linux/pci.h>
+#include <linux/iommufd.h>
 #include <linux/irqreturn.h>
 #include <linux/generic_pt/iommu.h>
 
@@ -495,6 +496,11 @@ struct pdom_iommu_info {
        u32 refcnt;     /* Count of attached dev/pasid per domain/IOMMU */
 };
 
+struct amd_iommu_viommu {
+       struct iommufd_viommu core;
+       struct protection_domain *parent; /* nest parent domain for this viommu */
+};
+
 /*
  * This structure contains generic data for  IOMMU protection domains
  * independent of their use.
index a223387eec5c3f6e52ee04b7c9c3ed80b62c7b50..f6a6ec90248a938ad774bd9b341a2313194da499 100644 (file)
@@ -3120,6 +3120,8 @@ const struct iommu_ops amd_iommu_ops = {
        .is_attach_deferred = amd_iommu_is_attach_deferred,
        .def_domain_type = amd_iommu_def_domain_type,
        .page_response = amd_iommu_page_response,
+       .get_viommu_size = amd_iommufd_get_viommu_size,
+       .viommu_init = amd_iommufd_viommu_init,
 };
 
 #ifdef CONFIG_IRQ_REMAP
index 72eaaa923d04a4637c9a49a8bffb3b767a8bdd32..eb6119bdcf12ee7de4fe174a4ed1056492ed00aa 100644 (file)
@@ -29,3 +29,19 @@ void *amd_iommufd_hw_info(struct device *dev, u32 *length, u32 *type)
 
        return hwinfo;
 }
+
+size_t amd_iommufd_get_viommu_size(struct device *dev, enum iommu_viommu_type viommu_type)
+{
+       return VIOMMU_STRUCT_SIZE(struct amd_iommu_viommu, core);
+}
+
+int amd_iommufd_viommu_init(struct iommufd_viommu *viommu, struct iommu_domain *parent,
+                           const struct iommu_user_data *user_data)
+{
+       struct protection_domain *pdom = to_pdomain(parent);
+       struct amd_iommu_viommu *aviommu = container_of(viommu, struct amd_iommu_viommu, core);
+
+       aviommu->parent = pdom;
+
+       return 0;
+}
index f880be80a30dd1f3fb76b9040bed1475018c9f5c..f05aad495b5b999f75fcc007b092916c3f7f5191 100644 (file)
@@ -8,8 +8,13 @@
 
 #if IS_ENABLED(CONFIG_AMD_IOMMU_IOMMUFD)
 void *amd_iommufd_hw_info(struct device *dev, u32 *length, u32 *type);
+size_t amd_iommufd_get_viommu_size(struct device *dev, enum iommu_viommu_type viommu_type);
+int amd_iommufd_viommu_init(struct iommufd_viommu *viommu, struct iommu_domain *parent,
+                           const struct iommu_user_data *user_data);
 #else
 #define amd_iommufd_hw_info NULL
+#define amd_iommufd_viommu_init NULL
+#define amd_iommufd_get_viommu_size NULL
 #endif /* CONFIG_AMD_IOMMU_IOMMUFD */
 
 #endif /* AMD_IOMMUFD_H */