Skip to content

Commit 8c4dc1a

Browse files
pran005jgunthorpe
authored andcommitted
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: dcd6a01 ("iommupt: Add map_pages op") Link: https://patch.msgid.link/r/20260330092609.2659235-1-praan@google.com Reported-by: syzbot+453eb7add07c3767adab@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/69c1d50b.a70a0220.3cae05.0001.GAE@google.com/ Signed-off-by: Pranjal Shrivastava <praan@google.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent aaca2aa commit 8c4dc1a

2 files changed

Lines changed: 0 additions & 32 deletions

File tree

drivers/iommu/iommufd/iommufd_test.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ enum {
3636
enum {
3737
MOCK_IOMMUPT_DEFAULT = 0,
3838
MOCK_IOMMUPT_HUGE,
39-
MOCK_IOMMUPT_AMDV1,
4039
};
4140

4241
/* These values are true for MOCK_IOMMUPT_DEFAULT */

drivers/iommu/iommufd/selftest.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -421,19 +421,6 @@ static const struct iommu_dirty_ops amdv1_mock_dirty_ops = {
421421
.set_dirty_tracking = mock_domain_set_dirty_tracking,
422422
};
423423

424-
static const struct iommu_domain_ops amdv1_ops = {
425-
IOMMU_PT_DOMAIN_OPS(amdv1),
426-
.free = mock_domain_free,
427-
.attach_dev = mock_domain_nop_attach,
428-
.set_dev_pasid = mock_domain_set_dev_pasid_nop,
429-
.iotlb_sync = &mock_iotlb_sync,
430-
};
431-
432-
static const struct iommu_dirty_ops amdv1_dirty_ops = {
433-
IOMMU_PT_DIRTY_OPS(amdv1),
434-
.set_dirty_tracking = mock_domain_set_dirty_tracking,
435-
};
436-
437424
static struct mock_iommu_domain *
438425
mock_domain_alloc_pgtable(struct device *dev,
439426
const struct iommu_hwpt_selftest *user_cfg, u32 flags)
@@ -477,24 +464,6 @@ mock_domain_alloc_pgtable(struct device *dev,
477464
mock->domain.dirty_ops = &amdv1_mock_dirty_ops;
478465
break;
479466
}
480-
481-
case MOCK_IOMMUPT_AMDV1: {
482-
struct pt_iommu_amdv1_cfg cfg = {};
483-
484-
cfg.common.hw_max_vasz_lg2 = 64;
485-
cfg.common.hw_max_oasz_lg2 = 52;
486-
cfg.common.features = BIT(PT_FEAT_DYNAMIC_TOP) |
487-
BIT(PT_FEAT_AMDV1_ENCRYPT_TABLES) |
488-
BIT(PT_FEAT_AMDV1_FORCE_COHERENCE);
489-
cfg.starting_level = 2;
490-
mock->domain.ops = &amdv1_ops;
491-
rc = pt_iommu_amdv1_init(&mock->amdv1, &cfg, GFP_KERNEL);
492-
if (rc)
493-
goto err_free;
494-
if (flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING)
495-
mock->domain.dirty_ops = &amdv1_dirty_ops;
496-
break;
497-
}
498467
default:
499468
rc = -EOPNOTSUPP;
500469
goto err_free;

0 commit comments

Comments
 (0)