From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Auger Subject: Re: [RFC PATCH] vfio/type1: Do not support IOMMUs that allow bypass Date: Fri, 16 Oct 2015 16:03:11 +0200 Message-ID: <5621039F.50609@linaro.org> References: <20151015205046.28129.50479.stgit@gimli.home> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org To: Alex Williamson Return-path: Received: from mail-wi0-f178.google.com ([209.85.212.178]:36868 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932195AbbJPODO (ORCPT ); Fri, 16 Oct 2015 10:03:14 -0400 Received: by wijq8 with SMTP id q8so12499772wij.0 for ; Fri, 16 Oct 2015 07:03:13 -0700 (PDT) In-Reply-To: <20151015205046.28129.50479.stgit@gimli.home> Sender: kvm-owner@vger.kernel.org List-ID: Hi Alex, On 10/15/2015 10:52 PM, Alex Williamson wrote: > 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 > --- > > 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 > > Alex > > drivers/vfio/vfio_iommu_type1.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > index 57d8c37..6afa9d4 100644 > --- a/drivers/vfio/vfio_iommu_type1.c > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -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; > >