From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45320) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcihG-0001fY-61 for qemu-devel@nongnu.org; Thu, 17 Sep 2015 19:34:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcihE-0001X4-VH for qemu-devel@nongnu.org; Thu, 17 Sep 2015 19:34:34 -0400 Date: Fri, 18 Sep 2015 09:31:57 +1000 From: David Gibson Message-ID: <20150917233157.GC2547@voom.fritz.box> References: <1442495357-26547-1-git-send-email-david@gibson.dropbear.id.au> <1442495357-26547-7-git-send-email-david@gibson.dropbear.id.au> <1442508864.23936.208.camel@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="A1Iwnsx6rNfRhs6P" Content-Disposition: inline In-Reply-To: <1442508864.23936.208.camel@redhat.com> Subject: Re: [Qemu-devel] [RFC PATCH 06/10] vfio: Allow hotplug of containers onto existing guest IOMMU mappings List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson Cc: lvivier@redhat.com, thuth@redhat.com, aik@ozlabs.ru, gwshan@linux.vnet.ibm.com, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, pbonzini@redhat.com --A1Iwnsx6rNfRhs6P Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 17, 2015 at 10:54:24AM -0600, Alex Williamson wrote: > On Thu, 2015-09-17 at 23:09 +1000, David Gibson wrote: > > At present the memory listener used by vfio to keep host IOMMU mappings > > in sync with the guest memory image assumes that if a guest IOMMU > > appears, then it has no existing mappings. > >=20 > > This may not be true if a VFIO device is hotplugged onto a guest bus > > which didn't previously include a VFIO device, and which has existing > > guest IOMMU mappings. > >=20 > > Therefore, use the memory_region_register_iommu_notifier_replay() > > function in order to fix this case, replaying existing guest IOMMU > > mappings, bringing the host IOMMU into sync with the guest IOMMU. > >=20 > > Signed-off-by: David Gibson > > --- > > hw/vfio/common.c | 34 +++++++++++++++++++--------------- > > 1 file changed, 19 insertions(+), 15 deletions(-) > >=20 > > diff --git a/hw/vfio/common.c b/hw/vfio/common.c > > index daaac48..543c38e 100644 > > --- a/hw/vfio/common.c > > +++ b/hw/vfio/common.c > > @@ -312,6 +312,22 @@ out: > > rcu_read_unlock(); > > } > > =20 > > +static hwaddr vfio_container_granularity(VFIOContainer *container) > > +{ > > + uint64_t pgsize; > > + > > + assert(container->iommu_data.iova_pgsizes); >=20 > return (hwaddr)1 << (ffsl(container->iommu_data.iova_pgsizes) - 1; Ah, yes, that should work. I didn't do it that way mostly because I tend to confuse myself when I try to remember exactly how ffs semantics work. --=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 --A1Iwnsx6rNfRhs6P Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJV+01sAAoJEGw4ysog2bOSvrUQALFbzBujjCSK945lqGCmL9X9 Ez6wyhPJmV7eRNTNCG6BvWCxTp1qKzu/ZT33HQJGzDLDCQ5xqgwwbRJeJGc8o7Z/ EllyGsKqFZwUfo6yiNSKdxc4gDHLo9tgujR+k8oJj3BIhihlcAhMD/UJTU03Acyb D5aEfFlBvfg8qvaiJRJMolo7xZfovOZluCryeknZSEk0j0l7AgIkbqVvigLwCqgz wMqgGRIADSe8OhoSB0uiD8PctWsgSLS5qCvvEUdqyj5sQHLozy+5ZWjElHUl4OC9 WD7yq4YgYuxjU7gNwIUaWClEz9MNdCv2lcfEVDPRXVJ9xTxnWU5t5IAnYiujqyiL owSpC+tvCz/PQsQwsHEKrCW3ptzhRRNI56V8Bz7wVcOgHO8lOG9hPoYqQQV7jge7 d1hp8eM5VoNAqZdUVZhJx8gdKhKWy70hJ0HM0vBQeHbWnyI7KiMXuNhqXRPjWY7q fjTGFwZ9yp3Stml7d4600I0kenehtEmgQqgpU7yepf+5dtVFm48hbWMEbpsaw0As 2UWmXbKfrmXLUeB4pRgxCKhXHrb+gQXL23T+5xeAL4DDMKfAK3HAHofbVj/kqp6W 9LYORTXy7+xpF+wHsGEHpfe0f9Flv/F1P5XwIedw0Slyj8JFRZiPNLoN+GCL0yKv ia35iqIESoNenbJrZKAg =EjTU -----END PGP SIGNATURE----- --A1Iwnsx6rNfRhs6P--