Skip to content

Commit 99d3fcf

Browse files
committed
2 parents 580fb8a + 8c4dc1a commit 99d3fcf

6 files changed

Lines changed: 8 additions & 39 deletions

File tree

drivers/iommu/iommufd/device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ iommufd_device_auto_get_domain(struct iommufd_device *idev, ioasid_t pasid,
866866
{
867867
/*
868868
* iommufd_hw_pagetable_attach() is called by
869-
* iommufd_hw_pagetable_alloc() in immediate attachment mode, same as
869+
* iommufd_hwpt_paging_alloc() in immediate attachment mode, same as
870870
* iommufd_device_do_attach(). So if we are in this mode then we prefer
871871
* to use the immediate_attach path as it supports drivers that can't
872872
* directly allocate a domain.

drivers/iommu/iommufd/eventq.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,10 @@ static ssize_t iommufd_fault_fops_write(struct file *filep, const char __user *b
187187

188188
mutex_lock(&fault->mutex);
189189
while (count > done) {
190-
rc = copy_from_user(&response, buf + done, response_size);
191-
if (rc)
190+
if (copy_from_user(&response, buf + done, response_size)) {
191+
rc = -EFAULT;
192192
break;
193+
}
193194

194195
static_assert((int)IOMMUFD_PAGE_RESP_SUCCESS ==
195196
(int)IOMMU_PAGE_RESP_SUCCESS);

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/pages.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@ static void iopt_revoke_notify(struct dma_buf_attachment *attach)
14501450
pages->dmabuf.phys.len = 0;
14511451
}
14521452

1453-
static struct dma_buf_attach_ops iopt_dmabuf_attach_revoke_ops = {
1453+
static const struct dma_buf_attach_ops iopt_dmabuf_attach_revoke_ops = {
14541454
.allow_peer2peer = true,
14551455
.invalidate_mappings = iopt_revoke_notify,
14561456
};

drivers/iommu/iommufd/selftest.c

Lines changed: 2 additions & 33 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;
@@ -636,7 +605,7 @@ static void mock_viommu_destroy(struct iommufd_viommu *viommu)
636605
if (mock_viommu->mmap_offset)
637606
iommufd_viommu_destroy_mmap(&mock_viommu->core,
638607
mock_viommu->mmap_offset);
639-
free_page((unsigned long)mock_viommu->page);
608+
free_pages((unsigned long)mock_viommu->page, 1);
640609
mutex_destroy(&mock_viommu->queue_mutex);
641610

642611
/* iommufd core frees mock_viommu and viommu */
@@ -870,7 +839,7 @@ static int mock_viommu_init(struct iommufd_viommu *viommu,
870839
iommufd_viommu_destroy_mmap(&mock_viommu->core,
871840
mock_viommu->mmap_offset);
872841
err_free_page:
873-
free_page((unsigned long)mock_viommu->page);
842+
free_pages((unsigned long)mock_viommu->page, 1);
874843
return rc;
875844
}
876845

drivers/iommu/iommufd/vfio_compat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static int iommufd_vfio_check_extension(struct iommufd_ctx *ictx,
283283
case VFIO_TYPE1_IOMMU:
284284
case VFIO_TYPE1v2_IOMMU:
285285
case VFIO_UNMAP_ALL:
286-
return 1;
286+
return !ictx->no_iommu_mode;
287287

288288
case VFIO_NOIOMMU_IOMMU:
289289
return IS_ENABLED(CONFIG_VFIO_NOIOMMU);

0 commit comments

Comments
 (0)