vfio/type1: Do not support IOMMUs that allow bypass
Subsystems (2)
RFC PATCH 1/1 vfio/type1: Do not support IOMMUs that allow bypass
We can only provide isolation if DMA is forced through the IOMMU aperture. Don't allow type1 to be used if this is not the case.
---
Eric, I see a number of IOMMU drivers enable this, do the ones you care about for ARM set geometry.force_aperture? Thanks,
Alex
drivers/vfio/vfio_iommu_type1.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/vfio/vfio_iommu_type1.c +12 -0
@@ -728,6 +728,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,struct vfio_group *group, *g;struct vfio_domain *domain, *d;struct bus_type *bus =NULL ; +struct iommu_domain_geometry geometry;int ret;mutex_lock (&iommu->lock);
@@ -762,6 +763,17 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, goto out_free; } +/* +* If a domain does not force DMA within the aperture, devices are not +* isolated and type1 is not an appropriate IOMMU model. +*/ + ret =iommu_domain_get_attr (domain->domain, +DOMAIN_ATTR_GEOMETRY , &geometry); +if (ret || !geometry.force_aperture) { + ret = -EPERM ; + goto out_domain; + } +if (iommu->nesting) {int attr =1 ;
Hi Alex,
Quoted 8 lines · Alex Williamson
We can only provide isolation if DMA is forced through the IOMMU aperture. Don't allow type1 to be used if this is not the case.
Signed-off-by Alex Williamson <[email protected]>---
Eric, I see a number of IOMMU drivers enable this, do the ones you care about for ARM set geometry.force_aperture? Thanks,
I am currently using arm-smmu.c. I don't see force_aperture being set.
Best Regards
Eric
Quoted 37 lines
Alex
drivers/vfio/vfio_iommu_type1.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/vfio/vfio_iommu_type1.c +12
-0@@ -728,6 +728,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,struct vfio_group *group, *g;struct vfio_domain *domain, *d;struct bus_type *bus =NULL ; +struct iommu_domain_geometry geometry;int ret;mutex_lock (&iommu->lock);@@ -762,6 +763,17 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, goto out_free; } +/* +* If a domain does not force DMA within the aperture, devices are not +* isolated and type1 is not an appropriate IOMMU model. +*/ + ret =iommu_domain_get_attr (domain->domain, +DOMAIN_ATTR_GEOMETRY , &geometry); +if (ret || !geometry.force_aperture) { + ret = -EPERM ; + goto out_domain; + } +if (iommu->nesting) {int attr =1 ;
Quoted 11 lines · Eric Auger
Hi Alex,
Quoted 8 lines · Alex Williamson
We can only provide isolation if DMA is forced through the IOMMU aperture. Don't allow type1 to be used if this is not the case.
Signed-off-by Alex Williamson <[email protected]>---
Eric, I see a number of IOMMU drivers enable this, do the ones you care about for ARM set geometry.force_aperture? Thanks,
I am currently using
arm-smmu.c. I don't seeforce_aperturebeing set.
Hi Will,
Would it be possible to add iommu_domain_geometry support to arm-smmu.c? In addition to this test to verify that DMA cannot bypass the IOMMU, I'd eventually like to pass the aperture information out through the VFIO API. Thanks,
Alex
Quoted 35 lines
Quoted 34 lines
drivers/vfio/vfio_iommu_type1.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/vfio/vfio_iommu_type1.c +12
-0@@ -728,6 +728,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,struct vfio_group *group, *g;struct vfio_domain *domain, *d;struct bus_type *bus =NULL ; +struct iommu_domain_geometry geometry;int ret;mutex_lock (&iommu->lock);@@ -762,6 +763,17 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, goto out_free; } +/* +* If a domain does not force DMA within the aperture, devices are not +* isolated and type1 is not an appropriate IOMMU model. +*/ + ret =iommu_domain_get_attr (domain->domain, +DOMAIN_ATTR_GEOMETRY , &geometry); +if (ret || !geometry.force_aperture) { + ret = -EPERM ; + goto out_domain; + } +if (iommu->nesting) {int attr =1 ;
Quoted 6 lines · Alex Williamson
Quoted 5 lines · Eric Auger
Hi Alex,
Quoted 3 lines · Alex Williamson
We can only provide isolation if DMA is forced through the IOMMU aperture. Don't allow type1 to be used if this is not the case.
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Signed-off-by Alex Williamson <[email protected]>---
Eric, I see a number of IOMMU drivers enable this, do the ones you care about for ARM set geometry.force_aperture? Thanks,
I am currently using
arm-smmu.c. I don't seeforce_aperturebeing set.Hi Will,
Hi Alex,
Quoted 4 lines
Would it be possible to add
iommu_domain_geometrysupport toarm-smmu.c? In addition to this test to verify that DMA cannot bypass the IOMMU, I'd eventually like to pass the aperture information out through the VFIO API. Thanks,
The slight snag here is that we don't know which SMMU in the system the domain is attached to at the point when the geometry is queried, so I can't give you an upper bound on the aperture. For example, if there is an SMMU with a 32-bit input address and another with a 48-bit input address.
We could play the same horrible games that we do with the pgsize bitmap, and truncate some global aperture everytime we probe an SMMU device, but I'd really like to have fewer hacks like that if possible. The root of the problem is still that domains are allocated for a bus, rather than an IOMMU instance.
Will
[cc +iommu]
Quoted 29 lines · Will Deacon
Quoted 6 lines · Alex Williamson
Quoted 5 lines · Eric Auger
Hi Alex,
Quoted 3 lines · Alex Williamson
We can only provide isolation if DMA is forced through the IOMMU aperture. Don't allow type1 to be used if this is not the case.
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Signed-off-by Alex Williamson <[email protected]>---
Eric, I see a number of IOMMU drivers enable this, do the ones you care about for ARM set geometry.force_aperture? Thanks,
I am currently using
arm-smmu.c. I don't seeforce_aperturebeing set.Hi Will,
Hi Alex,
Quoted 4 lines
Would it be possible to add
iommu_domain_geometrysupport toarm-smmu.c? In addition to this test to verify that DMA cannot bypass the IOMMU, I'd eventually like to pass the aperture information out through the VFIO API. Thanks,The slight snag here is that we don't know which SMMU in the system the domain is attached to at the point when the geometry is queried, so I can't give you an upper bound on the aperture. For example, if there is an SMMU with a 32-bit input address and another with a 48-bit input address.
Quoted 5 lines
We could play the same horrible games that we do with the pgsize bitmap, and truncate some global aperture everytime we probe an SMMU device, but I'd really like to have fewer hacks like that if possible. The root of the problem is still that domains are allocated for a bus, rather than an IOMMU instance.
Hi Will,
Yes, Intel VT-d has this issue as well. In theory we can have heterogeneous IOMMU hardware units (DRHDs) in a system and the upper bound of the geometry could be diminished if we add a less capable DRHD into the domain. I suspect this is more a theoretical problem than a practical one though as we're typically mixing similar DRHDs and I think we're still capable of 39-bit addressing in the least capable version per the spec.
In any case, I really want to start testing geometry.force_aperture, even if we're not yet comfortable to expose the IOMMU limits to the user. The vfio type1 shouldn't be enabled at all for underlying hardware that allows DMA bypass. Thanks,
Alex
Quoted 27 lines · Alex Williamson
Quoted 12 lines · Will Deacon
Quoted 4 lines · Alex Williamson
Would it be possible to add
iommu_domain_geometrysupport toarm-smmu.c? In addition to this test to verify that DMA cannot bypass the IOMMU, I'd eventually like to pass the aperture information out through the VFIO API. Thanks,The slight snag here is that we don't know which SMMU in the system the domain is attached to at the point when the geometry is queried, so I can't give you an upper bound on the aperture. For example, if there is an SMMU with a 32-bit input address and another with a 48-bit input address.
Quoted 5 lines
We could play the same horrible games that we do with the pgsize bitmap, and truncate some global aperture everytime we probe an SMMU device, but I'd really like to have fewer hacks like that if possible. The root of the problem is still that domains are allocated for a bus, rather than an IOMMU instance.
Yes, Intel VT-d has this issue as well. In theory we can have heterogeneous IOMMU hardware units (DRHDs) in a system and the upper bound of the geometry could be diminished if we add a less capable DRHD into the domain. I suspect this is more a theoretical problem than a practical one though as we're typically mixing similar DRHDs and I think we're still capable of 39-bit addressing in the least capable version per the spec.
Quoted 4 lines
In any case, I really want to start testing geometry.force_aperture, even if we're not yet comfortable to expose the IOMMU limits to the user. The vfio type1 shouldn't be enabled at all for underlying hardware that allows DMA bypass. Thanks,
Ok, I'll put it on my list of things to look at under the assumption that the actual aperture limits don't need to be accurate as long as DMA to an arbitrary unmapped address always faults.
Will
Quoted 28 lines · Will Deacon
Quoted 27 lines · Alex Williamson
Quoted 12 lines · Will Deacon
Quoted 4 lines · Alex Williamson
Would it be possible to add
iommu_domain_geometrysupport toarm-smmu.c? In addition to this test to verify that DMA cannot bypass the IOMMU, I'd eventually like to pass the aperture information out through the VFIO API. Thanks,The slight snag here is that we don't know which SMMU in the system the domain is attached to at the point when the geometry is queried, so I can't give you an upper bound on the aperture. For example, if there is an SMMU with a 32-bit input address and another with a 48-bit input address.
Quoted 5 lines
We could play the same horrible games that we do with the pgsize bitmap, and truncate some global aperture everytime we probe an SMMU device, but I'd really like to have fewer hacks like that if possible. The root of the problem is still that domains are allocated for a bus, rather than an IOMMU instance.
Yes, Intel VT-d has this issue as well. In theory we can have heterogeneous IOMMU hardware units (DRHDs) in a system and the upper bound of the geometry could be diminished if we add a less capable DRHD into the domain. I suspect this is more a theoretical problem than a practical one though as we're typically mixing similar DRHDs and I think we're still capable of 39-bit addressing in the least capable version per the spec.
Quoted 8 lines
Quoted 4 lines
In any case, I really want to start testing geometry.force_aperture, even if we're not yet comfortable to expose the IOMMU limits to the user. The vfio type1 shouldn't be enabled at all for underlying hardware that allows DMA bypass. Thanks,
Ok, I'll put it on my list of things to look at under the assumption that the actual aperture limits don't need to be accurate as long as DMA to an arbitrary unmapped address always faults.
I'm pretty sure we'd only ever set the aperture to the full input address range anyway (since we're not a GART-type thing), in which case we should only need to worry about unmatched streams that don't hit in a domain at all. Doesn't the disable_bypass option already cover that? (FWIW I hacked it up for v2 a while back, too[0]).
Robin.
[0]:http://www.linux-arm.org/git?p=linux-rm.git;a=commitdiff;h=23a251189fa3330b799a837bd8eb1023aa2dcea4
Quoted 38 lines · Robin Murphy
Quoted 28 lines · Will Deacon
Quoted 27 lines · Alex Williamson
Quoted 12 lines · Will Deacon
Quoted 4 lines · Alex Williamson
Would it be possible to add
iommu_domain_geometrysupport toarm-smmu.c? In addition to this test to verify that DMA cannot bypass the IOMMU, I'd eventually like to pass the aperture information out through the VFIO API. Thanks,The slight snag here is that we don't know which SMMU in the system the domain is attached to at the point when the geometry is queried, so I can't give you an upper bound on the aperture. For example, if there is an SMMU with a 32-bit input address and another with a 48-bit input address.
Quoted 5 lines
We could play the same horrible games that we do with the pgsize bitmap, and truncate some global aperture everytime we probe an SMMU device, but I'd really like to have fewer hacks like that if possible. The root of the problem is still that domains are allocated for a bus, rather than an IOMMU instance.
Yes, Intel VT-d has this issue as well. In theory we can have heterogeneous IOMMU hardware units (DRHDs) in a system and the upper bound of the geometry could be diminished if we add a less capable DRHD into the domain. I suspect this is more a theoretical problem than a practical one though as we're typically mixing similar DRHDs and I think we're still capable of 39-bit addressing in the least capable version per the spec.
Quoted 8 lines
Quoted 4 lines
In any case, I really want to start testing geometry.force_aperture, even if we're not yet comfortable to expose the IOMMU limits to the user. The vfio type1 shouldn't be enabled at all for underlying hardware that allows DMA bypass. Thanks,
Ok, I'll put it on my list of things to look at under the assumption that the actual aperture limits don't need to be accurate as long as DMA to an arbitrary unmapped address always faults.
Quoted 5 lines
I'm pretty sure we'd only ever set the aperture to the full input address range anyway (since we're not a GART-type thing), in which case we should only need to worry about unmatched streams that don't hit in a domain at all. Doesn't the
disable_bypassoption already cover that? (FWIW I hacked it up for v2 a while back, too[0]).
Well, the "full input address range" is tricky when you have multiple SMMU instances with different input address sizes. I can do something similar to the pgsize_bitmap.
I also don't think the disable_bypass option is what we're after -- this is about devices attached to a VFIO domain that can still mysteriously bypass the SMMU for some ranges AFAIU (and shouldn't be an issue for ARM).
Will