From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48833) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abcsW-0005i4-Il for qemu-devel@nongnu.org; Thu, 03 Mar 2016 18:41:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1abcsV-0004vh-4O for qemu-devel@nongnu.org; Thu, 03 Mar 2016 18:41:56 -0500 Date: Thu, 3 Mar 2016 22:22:00 +1100 From: David Gibson Message-ID: <20160303112200.GP1620@voom.redhat.com> References: <1456823441-46757-1-git-send-email-aik@ozlabs.ru> <1456823441-46757-16-git-send-email-aik@ozlabs.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="THYEXwetZJOK3OLY" Content-Disposition: inline In-Reply-To: <1456823441-46757-16-git-send-email-aik@ozlabs.ru> Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH qemu v13 15/16] vfio: Move iova_pgsizes from container to guest IOMMU List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy Cc: Alex Williamson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org --THYEXwetZJOK3OLY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 01, 2016 at 08:10:40PM +1100, Alexey Kardashevskiy wrote: > The page size is an attribute of an IOMMU, not a container as a container > may contain more just one IOMMU. >=20 > This moves iova_pgsizes from VFIOContainer to VFIOGuestIOMMU. > The following patch will use this. >=20 > This removes iova_pgsizes from Type1 IOMMU as it is not used there anyway > and when it will get guest visible IOMMU, it will use VFIOGuestIOMMU's > iova_pgsizes. >=20 > Signed-off-by: Alexey Kardashevskiy Hmm. This makes an important semantic change which.. I'm not sure is wrong, but certainly isn't adequately addressed in your commit message. The current iova_pgsizes is populated with information about the *host* IOMMU, whereas you're replacing it with information about the *guest* IOMMU. > --- > hw/vfio/common.c | 16 ++++------------ > include/hw/vfio/vfio-common.h | 2 +- > 2 files changed, 5 insertions(+), 13 deletions(-) >=20 > diff --git a/hw/vfio/common.c b/hw/vfio/common.c > index f2a03e0..42ef1eb 100644 > --- a/hw/vfio/common.c > +++ b/hw/vfio/common.c > @@ -313,9 +313,9 @@ out: > rcu_read_unlock(); > } > =20 > -static hwaddr vfio_container_granularity(VFIOContainer *container) > +static hwaddr vfio_container_granularity(VFIOGuestIOMMU *giommu) > { > - return (hwaddr)1 << ctz64(container->iova_pgsizes); > + return (hwaddr)1 << ctz64(giommu->iova_pgsizes); > } > =20 > static hwaddr vfio_iommu_page_mask(MemoryRegion *mr) > @@ -392,12 +392,13 @@ static void vfio_listener_region_add(VFIOMemoryList= ener *vlistener, > section->offset_within_address_space; > giommu->container =3D container; > giommu->n.notify =3D vfio_iommu_map_notify; > + giommu->iova_pgsizes =3D section->mr->iommu_ops->get_page_sizes(= section->mr); > QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next); > =20 > memory_region_register_iommu_notifier(giommu->iommu, &giommu->n); > giommu->iommu->iommu_ops->vfio_notify(section->mr, true); > memory_region_iommu_replay(giommu->iommu, &giommu->n, > - vfio_container_granularity(container), > + vfio_container_granularity(giommu), > false); > =20 > return; > @@ -743,14 +744,8 @@ static int vfio_connect_container(VFIOGroup *group, = AddressSpace *as) > container->min_iova =3D 0; > container->max_iova =3D (hwaddr)-1; > =20 > - /* Assume just 4K IOVA page size */ > - container->iova_pgsizes =3D 0x1000; > info.argsz =3D sizeof(info); > ret =3D ioctl(fd, VFIO_IOMMU_GET_INFO, &info); > - /* Ignore errors */ > - if ((ret =3D=3D 0) && (info.flags & VFIO_IOMMU_INFO_PGSIZES)) { > - container->iova_pgsizes =3D info.iova_pgsizes; > - } > } else if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_IOMMU) || > ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_v2_IOMMU))= { > struct vfio_iommu_spapr_tce_info info; > @@ -811,9 +806,6 @@ static int vfio_connect_container(VFIOGroup *group, A= ddressSpace *as) > } > container->min_iova =3D info.dma32_window_start; > container->max_iova =3D container->min_iova + info.dma32_window_= size - 1; > - > - /* Assume just 4K IOVA pages for now */ > - container->iova_pgsizes =3D 0x1000; > } else { > error_report("vfio: No available IOMMU models"); > ret =3D -EINVAL; > diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h > index bcbc5cb..48a1d7f 100644 > --- a/include/hw/vfio/vfio-common.h > +++ b/include/hw/vfio/vfio-common.h > @@ -80,7 +80,6 @@ typedef struct VFIOContainer { > * future > */ > hwaddr min_iova, max_iova; > - uint64_t iova_pgsizes; > QLIST_HEAD(, VFIOGuestIOMMU) giommu_list; > QLIST_HEAD(, VFIOGroup) group_list; > QLIST_ENTRY(VFIOContainer) next; > @@ -90,6 +89,7 @@ typedef struct VFIOGuestIOMMU { > VFIOContainer *container; > MemoryRegion *iommu; > hwaddr offset_within_address_space; > + uint64_t iova_pgsizes; > Notifier n; > QLIST_ENTRY(VFIOGuestIOMMU) giommu_next; > } VFIOGuestIOMMU; --=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 --THYEXwetZJOK3OLY Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJW2B5YAAoJEGw4ysog2bOSC64QAJSadfyFclOO4UYvCZQtvEfX lmC5Ghj5+nu/orY4IjReaCqCvM/E2a49PgokYeF9iNGOIjf+Vej7cj33PwxC6scm kO4VdgezDmUZ1nJWAfM9z8srNbJxzI46Y+JkKJnaI3jW2VGIhmnCWoYpMxys11Ff EGLTIlFLUzZ1mFvqCCGoxTl34OPCwiwLrhwdWlGlTrpojcTziQJ94KzEPee1+1M3 ruwbwdBSS2o4pENhxJoXJHzxiS5SPTiuCkak5e4t4+g2PCZaFdQNHzv5Nez3vir9 aIrBE0vzaJnfZok/K8vC/QxP0Qt1Aj3cH8CkZx8yH1YAVLKI8RsGYrVwZoaYooS1 +OhZn7uTVo4a6fV28ki6Le1bGiHPd/z0nsX/FfC+gVnQjtbD7pL4ujhUGWvJVsxM 813KAPjRqK1qNuiniaPP1eLOwnqj4WoyhJhV1llgoEcjt/BZew/S9CbwlhCoXXps gqAi78e0XrbDO0SbpABrv6VF1pTHiJCkDMDhWfRaYMeH+ESs6RvNLbjAnL6eqF9r CLUV5OIj996EhTBMDulK4cPitc0KJYAgM+SVmJrmy3y5ZLYKWV7UqVA/AtBX8dep 0W+W2c0rwDrnvwXOAd0k41H7jJAhq7LAJ47Uoif/rUdtOMTlI3q1JLDTlbCa8cww odLKglYSqTKdMFsPiaoL =Z57U -----END PGP SIGNATURE----- --THYEXwetZJOK3OLY--