Message ID | cover.1674849118.git.nicolinc@nvidia.com |
---|---|
Headers | show |
Series | iommu: Reject drivers with broken_unmanaged_domain | expand |
On 2023-01-27 20:04, Nicolin Chen wrote: > Add a sanity of the broken_unmanaged_domain flag to reject the use of > dma-iommu in the early stage, if the flag is set by the iommu driver. Realistically, iommu-dma will never be enabled on PPC32, let alone used. It will not be enabled on ARM until I've fixed any drivers which need fixing to work with it. We don't need to add dead code here. Thanks, Robin. > Suggested-by: Jason Gunthorpe <jgg@nvidia.com> > Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> > --- > drivers/iommu/dma-iommu.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > index f798c44e0903..f1e8d952b17d 100644 > --- a/drivers/iommu/dma-iommu.c > +++ b/drivers/iommu/dma-iommu.c > @@ -545,6 +545,9 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base, > if (!cookie || cookie->type != IOMMU_DMA_IOVA_COOKIE) > return -EINVAL; > > + if (WARN_ON(!device_iommu_unmanaged_supported(dev))) > + return -EINVAL; > + > iovad = &cookie->iovad; > > /* Use the smallest supported page size for IOVA granularity */
On Fri, Jan 27, 2023 at 09:59:50PM +0000, Robin Murphy wrote: > External email: Use caution opening links or attachments > > > On 2023-01-27 20:04, Nicolin Chen wrote: > > Add a sanity of the broken_unmanaged_domain flag to reject the use of > > dma-iommu in the early stage, if the flag is set by the iommu driver. > > Realistically, iommu-dma will never be enabled on PPC32, let alone used. > It will not be enabled on ARM until I've fixed any drivers which need > fixing to work with it. We don't need to add dead code here. OK. Sounds like I can drop this patch. Thanks Nicolin
> From: Nicolin Chen <nicolinc@nvidia.com> > Sent: Saturday, January 28, 2023 4:04 AM > > Hi all, > > Both IOMMU_DOMAIN_UNMANAGED and IOMMU_DOMAIN_DMA require > the support > of __IOMMU_DOMAIN_PAGING capability, i.e. iommu_map/unmap. > However, > some older iommu drivers do not fully support that, and these drivers > also do not advertise support for dma-iommu.c via IOMMU_DOMAIN_DMA, > or use arm_iommu_create_mapping(), so largely their implementations > of IOMMU_DOMAIN_UNMANAGED are untested. This means that a user like > vfio/iommufd does not likely work with them. > > Thus, mark all these drivers as having "broken" UNAMANGED domains and > add a new device_iommu_unmanaged_supported() API for vfio/iommufd > and > dma-iommu to refuse to work with these drivers. > Why not making an explicit way to mark which drivers are tested to support vfio/iommufd? Not sure whether pure code review is reliable to filter out 'broken' vs. 'non-broken'...