From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b65mN-0000U2-8c for qemu-devel@nongnu.org; Thu, 26 May 2016 20:37:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b65mI-0007xw-6y for qemu-devel@nongnu.org; Thu, 26 May 2016 20:37:30 -0400 Date: Fri, 27 May 2016 10:36:32 +1000 From: David Gibson Message-ID: <20160527003632.GK17226@voom.fritz.box> References: <1462344751-28281-1-git-send-email-aik@ozlabs.ru> <1462344751-28281-17-git-send-email-aik@ozlabs.ru> <20160513162559.39e9e4b9@t450s.home> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="8uW5FuPCb1tAG9uS" Content-Disposition: inline In-Reply-To: <20160513162559.39e9e4b9@t450s.home> Subject: Re: [Qemu-devel] [PATCH qemu v16 16/19] vfio: Add host side DMA window capabilities List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson Cc: Alexey Kardashevskiy , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Alexander Graf , Paolo Bonzini --8uW5FuPCb1tAG9uS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 13, 2016 at 04:25:59PM -0600, Alex Williamson wrote: > On Wed, 4 May 2016 16:52:28 +1000 > Alexey Kardashevskiy wrote: >=20 > > There are going to be multiple IOMMUs per a container. This moves > > the single host IOMMU parameter set to a list of VFIOHostDMAWindow. > >=20 > > This should cause no behavioral change and will be used later by > > the SPAPR TCE IOMMU v2 which will also add a vfio_host_win_del() helper. > >=20 > > Signed-off-by: Alexey Kardashevskiy > > Reviewed-by: David Gibson > > --- > > Changes: > > v16: > > * adjusted commit log with changes from v15 > >=20 > > v15: > > * s/vfio_host_iommu_add/vfio_host_win_add/ > > * s/VFIOHostIOMMU/VFIOHostDMAWindow/ > > --- > > hw/vfio/common.c | 65 +++++++++++++++++++++++++++++++++--= -------- > > include/hw/vfio/vfio-common.h | 9 ++++-- > > 2 files changed, 57 insertions(+), 17 deletions(-) > >=20 > > diff --git a/hw/vfio/common.c b/hw/vfio/common.c > > index 496eb82..3f2fb23 100644 > > --- a/hw/vfio/common.c > > +++ b/hw/vfio/common.c > > @@ -29,6 +29,7 @@ > > #include "exec/memory.h" > > #include "hw/hw.h" > > #include "qemu/error-report.h" > > +#include "qemu/range.h" > > #include "sysemu/kvm.h" > > #include "trace.h" > > =20 > > @@ -239,6 +240,45 @@ static int vfio_dma_map(VFIOContainer *container, = hwaddr iova, > > return -errno; > > } > > =20 > > +static VFIOHostDMAWindow *vfio_host_win_lookup(VFIOContainer *containe= r, > > + hwaddr min_iova, hwaddr= max_iova) > > +{ > > + VFIOHostDMAWindow *hostwin; > > + > > + QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) { > > + if (hostwin->min_iova <=3D min_iova && max_iova <=3D hostwin->= max_iova) { > > + return hostwin; > > + } > > + } > > + > > + return NULL; > > +} > > + > > +static int vfio_host_win_add(VFIOContainer *container, > > + hwaddr min_iova, hwaddr max_iova, > > + uint64_t iova_pgsizes) > > +{ > > + VFIOHostDMAWindow *hostwin; > > + > > + QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) { > > + if (ranges_overlap(min_iova, max_iova - min_iova + 1, > > + hostwin->min_iova, > > + hostwin->max_iova - hostwin->min_iova + 1))= { >=20 > Why does vfio_host_win_lookup() not also use ranges_overlap()? In > fact, why don't we call vfio_host_win_lookup here to find the conflict? >=20 > > + error_report("%s: Overlapped IOMMU are not enabled", __fun= c__); > > + return -1; >=20 > Nobody here tests the return value, shouldn't this be fatal? Hm, yes. I think hw_error() would be the right choice here. This would represent either a qemu programming error, or seriously unexpected behaviour from the host kernel. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --8uW5FuPCb1tAG9uS Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXR5aQAAoJEGw4ysog2bOS5pQP+gOghYV/v7AvBEJBjFEeOpBy eZKORydzWrtZmBYHi/xKk/v4ydJ+QbmjiIvl9/OziqJ/0K7dJWoZMcskdT7RKWuF FH+7xSuQzN49bZd8dfnKhhxdehL40aC044ln4hIC62IJ9X+r1m8irlvY1kK+ldSD haIgNVyhUcyHWtFXgZnYb6wHUQu5/TZrRNH+fLqr0nAx/xun8B3o96o4vP4XMgIO zDxOuZPJdx51VSOafvVaELR6K0Uy/zKjPOAyx3eEKDWTsKuyj4+kSaf80XCMmWHG dyr9n3fiqdsUUnrcX9s1fXMW0YgfrThLG58vWEJ0j7zVO4hRCCQwhUdb9FiOFdLC HQSmrHnbK0XpD+sFbvOvbPJc3ysy6bJ/2rl7lspt6I+YmW8S5lPq/SbjEpc9rihh hAgV085ZXGcYE+ULSn6lypQWhSKuO3hP0+giP7u7XzTN6r+VX8V/NtjTFMSbLUAS 0lEuBeCWSmrtA/ozf+gxFQI1jfmCe4a5s5vb4NJLD7qPX6QssEZZp6CDVJrksEl8 89K60T3Gqwkh8dt3s1FT+ba+pXQktDLn3Pnk9TNEKjLrRCsWRtHNK3ToPMpoU5Yp NBknUYWRhcplSGZTy7bDcC0stic+GP9R/wmpetBa/xCFPIASIvqvFWiT7EwhIKLC XdcRjUv/evRUzxOhRMmf =Ibgf -----END PGP SIGNATURE----- --8uW5FuPCb1tAG9uS--