Skip to contentSkip to conversation

iommufd/selftest: Remove MOCK_IOMMUPT_AMDV1 format

PATCH Applied Pranjal Shrivastava 2 participants 2 messages Mar 30 – Mar 31

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

PATCH v2 1/1 iommufd/selftest: Remove MOCK_IOMMUPT_AMDV1 format

syzbot found that allocating a mock domain with AMDV1 format could cause a WARN_ON because the selftest enabled DYNAMIC_TOP without providing the required driver_ops.

The AMDV1 format in the selftest was a placeholder and was not actually used by any of the existing selftests. Instead of adding dummy driver_ops to satisfy the requirements of a format we don't currently test, remove the AMDV1 format option from the selftest.

The MOCK_IOMMUPT_DEFAULT and MOCK_IOMMUPT_HUGE formats are unaffected as they use the amdv1_mock variant which does not enable DYNAMIC_TOP.

Fixes dcd6a011a8d5 ("iommupt: Add map_pages op")
Reported-by [email protected]
---
 drivers/iommu/iommufd/iommufd_test.h |  1 -
 drivers/iommu/iommufd/selftest.c     | 31 ----------------------------
 2 files changed, 32 deletions(-)
drivers/iommu/iommufd/iommufd_test.h +0 -1
index 73e73e1ec158..52b78cbcc920 100644
@@ -36,7 +36,6 @@ enum {
 enum {
 	MOCK_IOMMUPT_DEFAULT = 0,
 	MOCK_IOMMUPT_HUGE,
-	MOCK_IOMMUPT_AMDV1,
 };
 
 /* These values are true for MOCK_IOMMUPT_DEFAULT */
drivers/iommu/iommufd/selftest.c +0 -31
index 9607416f8069..af07c642a526 100644
@@ -421,19 +421,6 @@ static const struct iommu_dirty_ops amdv1_mock_dirty_ops = {
 	.set_dirty_tracking = mock_domain_set_dirty_tracking,
 };
 
-static const struct iommu_domain_ops amdv1_ops = {
-	IOMMU_PT_DOMAIN_OPS(amdv1),
-	.free = mock_domain_free,
-	.attach_dev = mock_domain_nop_attach,
-	.set_dev_pasid = mock_domain_set_dev_pasid_nop,
-	.iotlb_sync = &mock_iotlb_sync,
-};
-
-static const struct iommu_dirty_ops amdv1_dirty_ops = {
-	IOMMU_PT_DIRTY_OPS(amdv1),
-	.set_dirty_tracking = mock_domain_set_dirty_tracking,
-};
-
 static struct mock_iommu_domain *
 mock_domain_alloc_pgtable(struct device *dev,
 			  const struct iommu_hwpt_selftest *user_cfg, u32 flags)
@@ -477,24 +464,6 @@ mock_domain_alloc_pgtable(struct device *dev,
 			mock->domain.dirty_ops = &amdv1_mock_dirty_ops;
 		break;
 	}
-
-	case MOCK_IOMMUPT_AMDV1: {
-		struct pt_iommu_amdv1_cfg cfg = {};
-
-		cfg.common.hw_max_vasz_lg2 = 64;
-		cfg.common.hw_max_oasz_lg2 = 52;
-		cfg.common.features = BIT(PT_FEAT_DYNAMIC_TOP) |
-				      BIT(PT_FEAT_AMDV1_ENCRYPT_TABLES) |
-				      BIT(PT_FEAT_AMDV1_FORCE_COHERENCE);
-		cfg.starting_level = 2;
-		mock->domain.ops = &amdv1_ops;
-		rc = pt_iommu_amdv1_init(&mock->amdv1, &cfg, GFP_KERNEL);
-		if (rc)
-			goto err_free;
-		if (flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING)
-			mock->domain.dirty_ops = &amdv1_dirty_ops;
-		break;
-	}
 	default:
 		rc = -EOPNOTSUPP;
 		goto err_free;
Signature · 1 line
2.53.0.1018.g2bb0e51243-goog
#1 lore raw
Quoted 12 lines · Pranjal Shrivastava

syzbot found that allocating a mock domain with AMDV1 format could cause a WARN_ON because the selftest enabled DYNAMIC_TOP without providing the required driver_ops.

The AMDV1 format in the selftest was a placeholder and was not actually used by any of the existing selftests. Instead of adding dummy driver_ops to satisfy the requirements of a format we don't currently test, remove the AMDV1 format option from the selftest.

The MOCK_IOMMUPT_DEFAULT and MOCK_IOMMUPT_HUGE formats are unaffected as they use the amdv1_mock variant which does not enable DYNAMIC_TOP.

Quoted 8 lines
Fixes dcd6a011a8d5 ("iommupt: Add map_pages op")
Reported-by [email protected]
---
 drivers/iommu/iommufd/iommufd_test.h |  1 -
 drivers/iommu/iommufd/selftest.c     | 31 ----------------------------
 2 files changed, 32 deletions(-)

Applied to for-next

Thanks,
Jason