Skip to content

Commit 35890f8

Browse files
jgunthorpewilldeacon
authored andcommitted
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 f5c9ece ("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. Acked-by: Alex Williamson <alex.williamson@redhat.com> Reviewed-by: Mostafa Saleh <smostafa@google.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com> Reviewed-by: Donald Dutile <ddutile@redhat.com> Tested-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/1-v4-9e99b76f3518+3a8-smmuv3_nesting_jgg@nvidia.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 8e929cb commit 35890f8

File tree

7 files changed

+3
-63
lines changed

7 files changed

+3
-63
lines changed

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3378,21 +3378,6 @@ static struct iommu_group *arm_smmu_device_group(struct device *dev)
33783378
return group;
33793379
}
33803380

3381-
static 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-
33963381
static int arm_smmu_of_xlate(struct device *dev,
33973382
const struct of_phandle_args *args)
33983383
{
@@ -3514,7 +3499,6 @@ static struct iommu_ops arm_smmu_ops = {
35143499
.flush_iotlb_all = arm_smmu_flush_iotlb_all,
35153500
.iotlb_sync = arm_smmu_iotlb_sync,
35163501
.iova_to_phys = arm_smmu_iova_to_phys,
3517-
.enable_nesting = arm_smmu_enable_nesting,
35183502
.free = arm_smmu_domain_free_paging,
35193503
}
35203504
};

drivers/iommu/arm/arm-smmu/arm-smmu.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,21 +1558,6 @@ static struct iommu_group *arm_smmu_device_group(struct device *dev)
15581558
return group;
15591559
}
15601560

1561-
static 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-
15761561
static int arm_smmu_set_pgtable_quirks(struct iommu_domain *domain,
15771562
unsigned long quirks)
15781563
{
@@ -1656,7 +1641,6 @@ static struct iommu_ops arm_smmu_ops = {
16561641
.flush_iotlb_all = arm_smmu_flush_iotlb_all,
16571642
.iotlb_sync = arm_smmu_iotlb_sync,
16581643
.iova_to_phys = arm_smmu_iova_to_phys,
1659-
.enable_nesting = arm_smmu_enable_nesting,
16601644
.set_pgtable_quirks = arm_smmu_set_pgtable_quirks,
16611645
.free = arm_smmu_domain_free,
16621646
}

drivers/iommu/iommu.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,16 +2723,6 @@ static int __init iommu_init(void)
27232723
}
27242724
core_initcall(iommu_init);
27252725

2726-
int 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-
}
2734-
EXPORT_SYMBOL_GPL(iommu_enable_nesting);
2735-
27362726
int iommu_set_pgtable_quirks(struct iommu_domain *domain,
27372727
unsigned long quirk)
27382728
{

drivers/iommu/iommufd/vfio_compat.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,7 @@ static int iommufd_vfio_check_extension(struct iommufd_ctx *ictx,
291291
case VFIO_DMA_CC_IOMMU:
292292
return iommufd_vfio_cc_iommu(ictx);
293293

294-
/*
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:
294+
case __VFIO_RESERVED_TYPE1_NESTING_IOMMU:
300295
return 0;
301296

302297
/*

drivers/vfio/vfio_iommu_type1.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ struct vfio_iommu {
7272
uint64_t pgsize_bitmap;
7373
uint64_t num_non_pinned_groups;
7474
bool v2;
75-
bool nesting;
7675
bool dirty_page_tracking;
7776
struct list_head emulated_iommu_groups;
7877
};
@@ -2195,12 +2194,6 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
21952194
goto out_free_domain;
21962195
}
21972196

2198-
if (iommu->nesting) {
2199-
ret = iommu_enable_nesting(domain->domain);
2200-
if (ret)
2201-
goto out_domain;
2202-
}
2203-
22042197
ret = iommu_attach_group(domain->domain, group->iommu_group);
22052198
if (ret)
22062199
goto out_domain;
@@ -2541,9 +2534,7 @@ static void *vfio_iommu_type1_open(unsigned long arg)
25412534
switch (arg) {
25422535
case VFIO_TYPE1_IOMMU:
25432536
break;
2544-
case VFIO_TYPE1_NESTING_IOMMU:
2545-
iommu->nesting = true;
2546-
fallthrough;
2537+
case __VFIO_RESERVED_TYPE1_NESTING_IOMMU:
25472538
case VFIO_TYPE1v2_IOMMU:
25482539
iommu->v2 = true;
25492540
break;
@@ -2638,7 +2629,6 @@ static int vfio_iommu_type1_check_extension(struct vfio_iommu *iommu,
26382629
switch (arg) {
26392630
case VFIO_TYPE1_IOMMU:
26402631
case VFIO_TYPE1v2_IOMMU:
2641-
case VFIO_TYPE1_NESTING_IOMMU:
26422632
case VFIO_UNMAP_ALL:
26432633
return 1;
26442634
case VFIO_UPDATE_VADDR:

include/linux/iommu.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,6 @@ struct iommu_ops {
635635
* @enforce_cache_coherency: Prevent any kind of DMA from bypassing IOMMU_CACHE,
636636
* including no-snoop TLPs on PCIe or other platform
637637
* specific mechanisms.
638-
* @enable_nesting: Enable nesting
639638
* @set_pgtable_quirks: Set io page table quirks (IO_PGTABLE_QUIRK_*)
640639
* @free: Release the domain after use.
641640
*/
@@ -663,7 +662,6 @@ struct iommu_domain_ops {
663662
dma_addr_t iova);
664663

665664
bool (*enforce_cache_coherency)(struct iommu_domain *domain);
666-
int (*enable_nesting)(struct iommu_domain *domain);
667665
int (*set_pgtable_quirks)(struct iommu_domain *domain,
668666
unsigned long quirks);
669667

@@ -844,7 +842,6 @@ extern void iommu_group_put(struct iommu_group *group);
844842
extern int iommu_group_id(struct iommu_group *group);
845843
extern struct iommu_domain *iommu_group_default_domain(struct iommu_group *);
846844

847-
int iommu_enable_nesting(struct iommu_domain *domain);
848845
int iommu_set_pgtable_quirks(struct iommu_domain *domain,
849846
unsigned long quirks);
850847

include/uapi/linux/vfio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#define VFIO_EEH 5
3636

3737
/* Two-stage IOMMU */
38-
#define VFIO_TYPE1_NESTING_IOMMU 6 /* Implies v2 */
38+
#define __VFIO_RESERVED_TYPE1_NESTING_IOMMU 6 /* Implies v2 */
3939

4040
#define VFIO_SPAPR_TCE_v2_IOMMU 7
4141

0 commit comments

Comments
 (0)