From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anglH-0008Mu-3E for qemu-devel@nongnu.org; Wed, 06 Apr 2016 02:16:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anglF-0003l8-Sy for qemu-devel@nongnu.org; Wed, 06 Apr 2016 02:16:19 -0400 Date: Wed, 6 Apr 2016 15:52:11 +1000 From: David Gibson Message-ID: <20160406055211.GA16485@voom.fritz.box> References: <1459762426-18440-1-git-send-email-aik@ozlabs.ru> <1459762426-18440-11-git-send-email-aik@ozlabs.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="apg+fY3UKMMABzWO" Content-Disposition: inline In-Reply-To: <1459762426-18440-11-git-send-email-aik@ozlabs.ru> Subject: Re: [Qemu-devel] [PATCH qemu v15 10/17] memory: Add reporting of supported page sizes 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, Alexander Graf --apg+fY3UKMMABzWO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 04, 2016 at 07:33:39PM +1000, Alexey Kardashevskiy wrote: > Every IOMMU has some granularity which MemoryRegionIOMMUOps::translate > uses when translating, however this information is not available outside > the translate context for various checks. >=20 > This adds a get_page_sizes callback to MemoryRegionIOMMUOps and > a wrapper for it so IOMMU users (such as VFIO) can know the actual > page size(s) used by an IOMMU. >=20 > As IOMMU MR represents a guest IOMMU, this uses TARGET_PAGE_SIZE > as fallback. >=20 > This removes vfio_container_granularity() and uses new callback in > memory_region_iommu_replay() when replaying IOMMU mappings on added > IOMMU memory region. >=20 > Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson =2E. with the exception of one nit: [snip] > diff --git a/memory.c b/memory.c > index 95f7209..c37dbc9 100644 > --- a/memory.c > +++ b/memory.c > @@ -1512,12 +1512,14 @@ void memory_region_register_iommu_notifier(Memory= Region *mr, Notifier *n) > notifier_list_add(&mr->iommu_notify, n); > } > =20 > -void memory_region_iommu_replay(MemoryRegion *mr, Notifier *n, > - hwaddr granularity, bool is_write) > +void memory_region_iommu_replay(MemoryRegion *mr, Notifier *n, bool is_w= rite) > { > - hwaddr addr; > + hwaddr addr, granularity; > IOMMUTLBEntry iotlb; > =20 > + g_assert(mr->iommu_ops && mr->iommu_ops->get_page_sizes); > + granularity =3D (hwaddr)1 << ctz64(mr->iommu_ops->get_page_sizes(mr)= ); So here, replay requires that the get_page_sizes() callback be populated. However, if you move memory_region_iommu_get_page_sizes() just above this, you can use that and have the replay fall back to TARGET_PAGE_SIZE as well. > for (addr =3D 0; addr < memory_region_size(mr); addr +=3D granularit= y) { > iotlb =3D mr->iommu_ops->translate(mr, addr, is_write); > if (iotlb.perm !=3D IOMMU_NONE) { > @@ -1544,6 +1546,15 @@ void memory_region_notify_iommu(MemoryRegion *mr, > notifier_list_notify(&mr->iommu_notify, &entry); > } > =20 > +uint64_t memory_region_iommu_get_page_sizes(MemoryRegion *mr) > +{ > + assert(memory_region_is_iommu(mr)); > + if (mr->iommu_ops && mr->iommu_ops->get_page_sizes) { > + return mr->iommu_ops->get_page_sizes(mr); > + } > + return TARGET_PAGE_SIZE; > +} > + > void memory_region_set_log(MemoryRegion *mr, bool log, unsigned client) > { > uint8_t mask =3D 1 << client; --=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 --apg+fY3UKMMABzWO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXBKQLAAoJEGw4ysog2bOSfxYQANz6RFJr458zHeGk/b5jTHte tkSYHd09ukTShuLb3BR7TWVoRBHOwJVw2hqM5Xoy+E38VJY9sYUi/fDR63lEaPFx uPVfOgYVE0tkhvVDkNHQMOVZNLJUsOaQtx4ZmeJjfev3RzSGmVyMUjCs4F15Z966 KtYJGicH29RGSqCU45xZesPiC+WF/sLX4KYXISB/Mi+yAIRJBfLAdCaMqtF/CBj7 3w2Vr7LOOKYXBdBZi7f3uJfUMICaB+z8JN4GL9+nrms3OZtsX5UU48pCvSEyjGvO OPCjHZr2EXZYfX3/CoH+AKaiFdT6Wc4fK7uYRZ0TAVehWUokgXUBgkACsuxeIH/f LDhwjffECR9skTqHQ/ELoidD/70CU3BqzZQLXLFQb7u9lKB/rsFxu5qAJTkzltul aYPQD2i0eXRJs8+ycKlSz8pR6m1qP+Y7sCewI7nlyFf4hqpIvyFteCzIyNd2Hyi9 YnPOEnSvAiPtXy3R5/MQdXkpdZ99iOvRW5Wri3kOYbH7L9LlYf6WU1ONTK5TFyRG h4cqyjMvi+8Fh7weYw/HD5m84Ng4oLzaWd1DyTNI07Izh3X98yAp1hOutDdg+pPs zu+Ne6/HSz4UjRe8QIx1lcYy5ffyOUpaGQ0ZPKaplFF1hcPCIO5X+gPP4p/4yiho g+3bubNJxoENMONG8I+X =5iZn -----END PGP SIGNATURE----- --apg+fY3UKMMABzWO--