History

vfio: Remove VFIO_TYPE1_NESTING_IOMMU

This control causes the ARM SMMU drivers to choose a stage 2 implementation for the IO pagetable (vs the stage 1 usual default), however this choice has no significant visible impact to the VFIO user. Further qemu never implemented this and no other userspace user is known. The original description in commit f5c9ecebaf2a ("vfio/iommu_type1: add new VFIO_TYPE1_NESTING_IOMMU IOMMU type") suggested this was to "provide SMMU translation services to the guest operating system" however the rest of the API to set the guest table pointer for the stage 1 and manage invalidation was never completed, or at least never upstreamed, rendering this part useless dead code. Upstream has now settled on iommufd as the uAPI for controlling nested translation. Choosing the stage 2 implementation should be done by through the IOMMU_HWPT_ALLOC_NEST_PARENT flag during domain allocation. Remove VFIO_TYPE1_NESTING_IOMMU and everything under it including the enable_nesting iommu_domain_op. Just in-case there is some userspace using this continue to treat requesting it as a NOP, but do not advertise support any more.

Jason Gunthorpe committed 2 years ago

Commit 35890f81 parent 8e929cb7 files · +3 −63Browse files

Unified · Split

7 files
  1. drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +0 −16
  2. drivers/iommu/arm/arm-smmu/arm-smmu.c +0 −16
  3. drivers/iommu/iommu.c +0 −10
  4. drivers/iommu/iommufd/vfio_compat.c +1 −6
  5. drivers/vfio/vfio_iommu_type1.c +1 −11
  6. include/linux/iommu.h +0 −3
  7. include/uapi/linux/vfio.h +1 −1
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c+0−16
@@ -3378,21 +3378,6 @@ static struct iommu_group *arm_smmu_device_group(struct device *dev) · 3377 unmodified lines
3378 return group;3378 return group;
3379}3379}
3380 3380
3381static int arm_smmu_enable_nesting(struct iommu_domain *domain)
3382{
3383 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
3384 int ret = 0;
3385
3386 mutex_lock(&smmu_domain->init_mutex);
3387 if (smmu_domain->smmu)
3388 ret = -EPERM;
3389 else
3390 smmu_domain->stage = ARM_SMMU_DOMAIN_S2;
3391 mutex_unlock(&smmu_domain->init_mutex);
3392
3393 return ret;
3394}
3395
3396static int arm_smmu_of_xlate(struct device *dev,3381static int arm_smmu_of_xlate(struct device *dev,
3397 const struct of_phandle_args *args)3382 const struct of_phandle_args *args)
3398{3383{
@@ -3514,7 +3499,6 @@ static struct iommu_ops arm_smmu_ops = { · 115 unmodified lines
3514 .flush_iotlb_all = arm_smmu_flush_iotlb_all,3499 .flush_iotlb_all = arm_smmu_flush_iotlb_all,
3515 .iotlb_sync = arm_smmu_iotlb_sync,3500 .iotlb_sync = arm_smmu_iotlb_sync,
3516 .iova_to_phys = arm_smmu_iova_to_phys,3501 .iova_to_phys = arm_smmu_iova_to_phys,
3517 .enable_nesting = arm_smmu_enable_nesting,
3518 .free = arm_smmu_domain_free_paging,3502 .free = arm_smmu_domain_free_paging,
3519 }3503 }
3520};3504};
drivers/iommu/arm/arm-smmu/arm-smmu.c+0−16
@@ -1558,21 +1558,6 @@ static struct iommu_group *arm_smmu_device_group(struct device *dev) · 1557 unmodified lines
1558 return group;1558 return group;
1559}1559}
1560 1560
1561static int arm_smmu_enable_nesting(struct iommu_domain *domain)
1562{
1563 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
1564 int ret = 0;
1565
1566 mutex_lock(&smmu_domain->init_mutex);
1567 if (smmu_domain->smmu)
1568 ret = -EPERM;
1569 else
1570 smmu_domain->stage = ARM_SMMU_DOMAIN_NESTED;
1571 mutex_unlock(&smmu_domain->init_mutex);
1572
1573 return ret;
1574}
1575
1576static int arm_smmu_set_pgtable_quirks(struct iommu_domain *domain,1561static int arm_smmu_set_pgtable_quirks(struct iommu_domain *domain,
1577 unsigned long quirks)1562 unsigned long quirks)
1578{1563{
@@ -1656,7 +1641,6 @@ static struct iommu_ops arm_smmu_ops = { · 77 unmodified lines
1656 .flush_iotlb_all = arm_smmu_flush_iotlb_all,1641 .flush_iotlb_all = arm_smmu_flush_iotlb_all,
1657 .iotlb_sync = arm_smmu_iotlb_sync,1642 .iotlb_sync = arm_smmu_iotlb_sync,
1658 .iova_to_phys = arm_smmu_iova_to_phys,1643 .iova_to_phys = arm_smmu_iova_to_phys,
1659 .enable_nesting = arm_smmu_enable_nesting,
1660 .set_pgtable_quirks = arm_smmu_set_pgtable_quirks,1644 .set_pgtable_quirks = arm_smmu_set_pgtable_quirks,
1661 .free = arm_smmu_domain_free,1645 .free = arm_smmu_domain_free,
1662 }1646 }
drivers/iommu/iommu.c+0−10
@@ -2723,16 +2723,6 @@ static int __init iommu_init(void) · 2722 unmodified lines
2723}2723}
2724core_initcall(iommu_init);2724core_initcall(iommu_init);
2725 2725
2726int iommu_enable_nesting(struct iommu_domain *domain)
2727{
2728 if (domain->type != IOMMU_DOMAIN_UNMANAGED)
2729 return -EINVAL;
2730 if (!domain->ops->enable_nesting)
2731 return -EINVAL;
2732 return domain->ops->enable_nesting(domain);
2733}
2734EXPORT_SYMBOL_GPL(iommu_enable_nesting);
2735
2736int iommu_set_pgtable_quirks(struct iommu_domain *domain,2726int iommu_set_pgtable_quirks(struct iommu_domain *domain,
2737 unsigned long quirk)2727 unsigned long quirk)
2738{2728{
drivers/iommu/iommufd/vfio_compat.c+1−6
@@ -291,12 +291,7 @@ static int iommufd_vfio_check_extension(struct iommufd_ctx *ictx, · 290 unmodified lines
291 case VFIO_DMA_CC_IOMMU:291 case VFIO_DMA_CC_IOMMU:
292 return iommufd_vfio_cc_iommu(ictx);292 return iommufd_vfio_cc_iommu(ictx);
293 293
294 /*294 case __VFIO_RESERVED_TYPE1_NESTING_IOMMU:
295 * This is obsolete, and to be removed from VFIO. It was an incomplete
296 * idea that got merged.
297 * https://lore.kernel.org/kvm/0-v1-0093c9b0e345+19-vfio_no_nesting_jgg@nvidia.com/
298 */
299 case VFIO_TYPE1_NESTING_IOMMU:
300 return 0;295 return 0;
301 296
302 /*297 /*
drivers/vfio/vfio_iommu_type1.c+1−11
@@ -72,7 +72,6 @@ struct vfio_iommu { · 71 unmodified lines
72 uint64_t pgsize_bitmap;72 uint64_t pgsize_bitmap;
73 uint64_t num_non_pinned_groups;73 uint64_t num_non_pinned_groups;
74 bool v2;74 bool v2;
75 bool nesting;
76 bool dirty_page_tracking;75 bool dirty_page_tracking;
77 struct list_head emulated_iommu_groups;76 struct list_head emulated_iommu_groups;
78};77};
@@ -2195,12 +2194,6 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, · 2116 unmodified lines
2195 goto out_free_domain;2194 goto out_free_domain;
2196 }2195 }
2197 2196
2198 if (iommu->nesting) {
2199 ret = iommu_enable_nesting(domain->domain);
2200 if (ret)
2201 goto out_domain;
2202 }
2203
2204 ret = iommu_attach_group(domain->domain, group->iommu_group);2197 ret = iommu_attach_group(domain->domain, group->iommu_group);
2205 if (ret)2198 if (ret)
2206 goto out_domain;2199 goto out_domain;
@@ -2541,9 +2534,7 @@ static void *vfio_iommu_type1_open(unsigned long arg) · 334 unmodified lines
2541 switch (arg) {2534 switch (arg) {
2542 case VFIO_TYPE1_IOMMU:2535 case VFIO_TYPE1_IOMMU:
2543 break;2536 break;
2544 case VFIO_TYPE1_NESTING_IOMMU:2537 case __VFIO_RESERVED_TYPE1_NESTING_IOMMU:
2545 iommu->nesting = true;
2546 fallthrough;
2547 case VFIO_TYPE1v2_IOMMU:2538 case VFIO_TYPE1v2_IOMMU:
2548 iommu->v2 = true;2539 iommu->v2 = true;
2549 break;2540 break;
@@ -2638,7 +2629,6 @@ static int vfio_iommu_type1_check_extension(struct vfio_iommu *iommu, · 88 unmodified lines
2638 switch (arg) {2629 switch (arg) {
2639 case VFIO_TYPE1_IOMMU:2630 case VFIO_TYPE1_IOMMU:
2640 case VFIO_TYPE1v2_IOMMU:2631 case VFIO_TYPE1v2_IOMMU:
2641 case VFIO_TYPE1_NESTING_IOMMU:
2642 case VFIO_UNMAP_ALL:2632 case VFIO_UNMAP_ALL:
2643 return 1;2633 return 1;
2644 case VFIO_UPDATE_VADDR:2634 case VFIO_UPDATE_VADDR:
include/linux/iommu.h+0−3
@@ -635,7 +635,6 @@ struct iommu_ops { · 634 unmodified lines
635 * @enforce_cache_coherency: Prevent any kind of DMA from bypassing IOMMU_CACHE,635 * @enforce_cache_coherency: Prevent any kind of DMA from bypassing IOMMU_CACHE,
636 * including no-snoop TLPs on PCIe or other platform636 * including no-snoop TLPs on PCIe or other platform
637 * specific mechanisms.637 * specific mechanisms.
638 * @enable_nesting: Enable nesting
639 * @set_pgtable_quirks: Set io page table quirks (IO_PGTABLE_QUIRK_*)638 * @set_pgtable_quirks: Set io page table quirks (IO_PGTABLE_QUIRK_*)
640 * @free: Release the domain after use.639 * @free: Release the domain after use.
641 */640 */
@@ -663,7 +662,6 @@ struct iommu_domain_ops { · 21 unmodified lines
663 dma_addr_t iova);662 dma_addr_t iova);
664 663
665 bool (*enforce_cache_coherency)(struct iommu_domain *domain);664 bool (*enforce_cache_coherency)(struct iommu_domain *domain);
666 int (*enable_nesting)(struct iommu_domain *domain);
667 int (*set_pgtable_quirks)(struct iommu_domain *domain,665 int (*set_pgtable_quirks)(struct iommu_domain *domain,
668 unsigned long quirks);666 unsigned long quirks);
669 667
@@ -844,7 +842,6 @@ extern void iommu_group_put(struct iommu_group *group); · 174 unmodified lines
844extern int iommu_group_id(struct iommu_group *group);842extern int iommu_group_id(struct iommu_group *group);
845extern struct iommu_domain *iommu_group_default_domain(struct iommu_group *);843extern struct iommu_domain *iommu_group_default_domain(struct iommu_group *);
846 844
847int iommu_enable_nesting(struct iommu_domain *domain);
848int iommu_set_pgtable_quirks(struct iommu_domain *domain,845int iommu_set_pgtable_quirks(struct iommu_domain *domain,
849 unsigned long quirks);846 unsigned long quirks);
850 847
include/uapi/linux/vfio.h+1−1
@@ -35,7 +35,7 @@ · 34 unmodified lines
35#define VFIO_EEH 535#define VFIO_EEH 5
36 36
37/* Two-stage IOMMU */37/* Two-stage IOMMU */
38#define VFIO_TYPE1_NESTING_IOMMU 6 /* Implies v2 */38#define __VFIO_RESERVED_TYPE1_NESTING_IOMMU 6 /* Implies v2 */
39 39
40#define VFIO_SPAPR_TCE_v2_IOMMU 740#define VFIO_SPAPR_TCE_v2_IOMMU 7
41 41

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t