Skip to contentSkip to conversation

iommu/amd: Test for PAGING domains before freeing a domain

PATCH In review Jason Gunthorpe 2 participants 2 messages Sep 10, 2024 – Sep 11, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/amd: Test for PAGING domains before freeing a domain

This domain free function can be called for IDENTITY and SVA domains too, and they don't have page tables. For now protect against this by checking the type. Eventually the different types should have their own free functions.

Fixes 485534bfccb2 ("iommu/amd: Remove conditions from domain free paths")
---
 drivers/iommu/amd/iommu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Joerg please pick or squash for this cycle, thanks

drivers/iommu/amd/iommu.c +2 -1
index 2d0a681a205211..154f90e7b98e1d 100644
@@ -2257,7 +2257,8 @@ static void cleanup_domain(struct protection_domain *domain)
 void protection_domain_free(struct protection_domain *domain)
 {
 	WARN_ON(!list_empty(&domain->dev_list));
-	free_io_pgtable_ops(&domain->iop.pgtbl.ops);
+	if (domain->domain.type & __IOMMU_DOMAIN_PAGING)
+		free_io_pgtable_ops(&domain->iop.pgtbl.ops);
 	domain_id_free(domain->id);
 	kfree(domain);
 }

base-commit: 22c91287502b4bfc2899a1006709eec8273cf052

Signature · 1 line
2.46.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jason Gunthorpe

This domain free function can be called for IDENTITY and SVA domains too, and they don't have page tables. For now protect against this by checking the type. Eventually the different types should have their own free functions.

Fixes 485534bfccb2 ("iommu/amd: Remove conditions from domain free paths")

-Vasant

Quoted 22 lines
---
 drivers/iommu/amd/iommu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Joerg please pick or squash for this cycle, thanks

drivers/iommu/amd/iommu.c +2 -1
index 2d0a681a205211..154f90e7b98e1d 100644
@@ -2257,7 +2257,8 @@ static void cleanup_domain(struct protection_domain *domain)
 void protection_domain_free(struct protection_domain *domain)
 {
 	WARN_ON(!list_empty(&domain->dev_list));
-	free_io_pgtable_ops(&domain->iop.pgtbl.ops);
+	if (domain->domain.type & __IOMMU_DOMAIN_PAGING)
+		free_io_pgtable_ops(&domain->iop.pgtbl.ops);
 	domain_id_free(domain->id);
 	kfree(domain);
 }

base-commit: 22c91287502b4bfc2899a1006709eec8273cf052