From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abLth-0002y9-Bq for qemu-devel@nongnu.org; Thu, 03 Mar 2016 00:34:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1abLtg-0003hE-1R for qemu-devel@nongnu.org; Thu, 03 Mar 2016 00:34:01 -0500 Date: Thu, 3 Mar 2016 16:33:52 +1100 From: David Gibson Message-ID: <20160303053352.GI1620@voom.redhat.com> References: <1456823441-46757-1-git-send-email-aik@ozlabs.ru> <1456823441-46757-9-git-send-email-aik@ozlabs.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="vs0rQTeTompTJjtd" Content-Disposition: inline In-Reply-To: <1456823441-46757-9-git-send-email-aik@ozlabs.ru> Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH qemu v13 08/16] 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 --vs0rQTeTompTJjtd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 01, 2016 at 08:10:33PM +1100, 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 > The qemu_real_host_page_mask is used as fallback. >=20 > Signed-off-by: Alexey Kardashevskiy I'm going to have to see how this gets used to really analyze it. But, a preliminary comment: Once this is added, it should be possible to remove the explicit page size parameter from the iommu_replay function (since it could be derived from the IOMMU page sizes). > --- > Changes: > v4: > * s/1< --- > hw/ppc/spapr_iommu.c | 8 ++++++++ > include/exec/memory.h | 11 +++++++++++ > memory.c | 9 +++++++++ > 3 files changed, 28 insertions(+) >=20 > diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c > index 67a8356..4c52cf4 100644 > --- a/hw/ppc/spapr_iommu.c > +++ b/hw/ppc/spapr_iommu.c > @@ -143,6 +143,13 @@ static int spapr_tce_vfio_notify(MemoryRegion *iommu= , bool attached) > return spapr_tce_vfio_notify_owner(tcet->owner, tcet, attached); > } > =20 > +static uint64_t spapr_tce_get_page_sizes(MemoryRegion *iommu) > +{ > + sPAPRTCETable *tcet =3D container_of(iommu, sPAPRTCETable, iommu); > + > + return 1ULL << tcet->page_shift; > +} > + > static int spapr_tce_table_post_load(void *opaque, int version_id) > { > sPAPRTCETable *tcet =3D SPAPR_TCE_TABLE(opaque); > @@ -175,6 +182,7 @@ static const VMStateDescription vmstate_spapr_tce_tab= le =3D { > static MemoryRegionIOMMUOps spapr_iommu_ops =3D { > .translate =3D spapr_tce_translate_iommu, > .vfio_notify =3D spapr_tce_vfio_notify, > + .get_page_sizes =3D spapr_tce_get_page_sizes, > }; > =20 > static int spapr_tce_table_realize(DeviceState *dev) > diff --git a/include/exec/memory.h b/include/exec/memory.h > index 9f82629..c34e67c 100644 > --- a/include/exec/memory.h > +++ b/include/exec/memory.h > @@ -152,6 +152,8 @@ struct MemoryRegionIOMMUOps { > IOMMUTLBEntry (*translate)(MemoryRegion *iommu, hwaddr addr, bool is= _write); > /* Called when VFIO starts/stops using this */ > int (*vfio_notify)(MemoryRegion *iommu, bool attached); > + /* Returns supported page sizes */ > + uint64_t (*get_page_sizes)(MemoryRegion *iommu); > }; > =20 > typedef struct CoalescedMemoryRange CoalescedMemoryRange; > @@ -576,6 +578,15 @@ static inline bool memory_region_is_iommu(MemoryRegi= on *mr) > =20 > =20 > /** > + * memory_region_iommu_get_page_sizes: get supported page sizes in an io= mmu > + * > + * Returns %bitmap of supported page sizes for an iommu. > + * > + * @mr: the memory region being queried > + */ > +uint64_t memory_region_iommu_get_page_sizes(MemoryRegion *mr); > + > +/** > * memory_region_notify_iommu: notify a change in an IOMMU translation e= ntry. > * > * @mr: the memory region that was changed > diff --git a/memory.c b/memory.c > index 0dd9695..5d8453d 100644 > --- a/memory.c > +++ b/memory.c > @@ -1462,6 +1462,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 qemu_real_host_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 --vs0rQTeTompTJjtd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJW18zAAAoJEGw4ysog2bOSeS0QALyxKnbkFSvdtSnT1JKaii6w +plFUdN+S+MbGPVYpYx2TQvtFOrqF0VUmjly+RzCERzsj/0WhptjFYGD781wl2LA j3dSDJGOrCkUgXvxDQTkMnBf36y64LFDGM43J+9HtUB1CGlRI2J3HCqGEmA0T5DN FnAtvK1vfIRQ/Mxb/lZVMECT8dGCAlVBiJt0LEJnv9jwhyWV9APLh+Gac5FGErq6 DF/WiXil2ZDXINY+CQbzY2ok9619qzlOocHeRSb/2G3DjVhRRiYsvUU07dgzU4XX DclkVwcAyawfZCUD6u+h4Feb3rhKTmuLZw1I6xtrHLLXsqzH8ptxU0i9lNcygG/6 Gv5x36VJhY7E4nDxylSVC+ym6XG49WnKI1f8MVey4jWJ+d+g5UZAwerd/Mg8HjIs hSExQ7Y4MF6puizYC6lNLy+WsuGLfLz8YVz40OMQlBQp6LK3dGqLXD+kStrp5ZKA AAMZqFnvGkKOrACUzCIIRIA7zKWw+QhsvBb8kpVXeP2JhfNownZBOpdkR2sf0pDI MEVEXfuIXdRWv6UleqhF5XsxvLwua569APgUg1tRC/OTt6WHL4QLJNXeXFQik2F+ r9tkWYxsTHAeIc/PpYVzUjwUoYafzQeL2ZAsX0C28PDhTgJX42FnSyqrOQBq5D8J DA9+qr+CWSYwHF3Ck22G =7hdj -----END PGP SIGNATURE----- --vs0rQTeTompTJjtd--