From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfRHA-0005DF-Qv for qemu-devel@nongnu.org; Fri, 25 Sep 2015 07:34:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfRH7-00026w-GM for qemu-devel@nongnu.org; Fri, 25 Sep 2015 07:34:52 -0400 Date: Fri, 25 Sep 2015 21:33:49 +1000 From: David Gibson Message-ID: <20150925113349.GL11620@voom.redhat.com> References: <1443069231-14856-1-git-send-email-david@gibson.dropbear.id.au> <1443069231-14856-6-git-send-email-david@gibson.dropbear.id.au> <56052DEC.6040500@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="c8JyeaiReRNoiMDS" Content-Disposition: inline In-Reply-To: <56052DEC.6040500@redhat.com> Subject: Re: [Qemu-devel] [PATCH 5/7] memory: Allow replay of IOMMU mapping notifications List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: lvivier@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org, abologna@redhat.com, alex.williamson@redhat.com, qemu-ppc@nongnu.org --c8JyeaiReRNoiMDS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 25, 2015 at 01:20:12PM +0200, Paolo Bonzini wrote: >=20 >=20 > On 24/09/2015 06:33, David Gibson wrote: > > When we have guest visible IOMMUs, we allow notifiers to be registered > > which will be informed of all changes to IOMMU mappings. This is used = by > > vfio to keep the host IOMMU mappings in sync with guest IOMMU mappings. > >=20 > > However, unlike with a memory region listener, an iommu notifier won't = be > > told about any mappings which already exist in the (guest) IOMMU at the > > time it is registered. This can cause problems if hotplugging a VFIO > > device onto a guest bus which had existing guest IOMMU mappings, but di= dn't > > previously have an VFIO devices (and hence no host IOMMU mappings). > >=20 > > This adds a memory_region_register_iommu_notifier_replay() function to > > handle this case. As well as registering the new notifier it replays > > existing mappings. Because the IOMMU memory region doesn't internally > > remember the granularity of the guest IOMMU it has a small hack where t= he > > caller must specify a granularity at which to replay mappings. > >=20 > > If there are finer mappings in the guest IOMMU these will be reported in > > the iotlb structures passed to the notifier which it must handle (proba= bly > > causing it to flag an error). This isn't new - the VFIO iommu notifier > > must already handle notifications about guest IOMMU mappings too short > > for it to represent in the host IOMMU. > >=20 > > Signed-off-by: David Gibson >=20 > The patch is okay, just two questions: >=20 > 1) Is there a case where using the no-replay functions makes sense? I'm not sure. I think vfio is the only user so far, so I guess that's technically a no. I was reluctant to change the interface and semantics just off the bat, though. > 2) You could add a ->replay function to the iommu_ops to optimize it, if > you want. Yes. Originally I was going to implement with a ->replay function, before I realised I didn't actually need it. I figure we can optimize when and if it proves necessary. --=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 --c8JyeaiReRNoiMDS Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWBTEcAAoJEGw4ysog2bOSAUgP/3Wmn3ESj5WvuG1LSl6HjT2f BHQpClCvJiLzWg2u9tiN3ZZ13ZafDVzFgvSrE95dvWSgOtZHk9k2MJPoGEPQcL2m Ik4ZpXb8F+doG8+0LmfmJ6i/ikxfYntUiAUI5aJMj7wmDzVcPWdyHV6Tp5QKaqpO OI4xGCxFGjlSvJAytjWqxIJNN7ANWQgJfVORDWsy/RYt5ihYa8cqhOjLUh+bkAu3 Q4HodtYvh/PgPyc/hSSrKce+PIr1BPc9gtb4fN7Hqxo1hsKt7lvmSF3m9upsDqa1 M6rzedskVTGIjPdUQ5bnRCCKRyMgUGRKHipxpsuqgccsNk3ajKnCsjWTk3ORUU4/ XiV2R4suG6oP+EZ2CIWR6lIsrKmgV58o33T3cQZ+UtQ2byz2ZQXiUYDBplFKIdVc z2a+2PWrLzJfL+HJxh2yNSqokP8D6+Bw9T10W3vgVpAnjVQScJtBkzuFtHgL7FQn u135HSED9Q/sTMKOT1RDNRSaS6n1d9v/0uL3vk+4I95c3gzXaJYUiYSzWZ12PSFi pm4XpOeJmQ65d6TPRWQtAdUn8Brj7nOwsalMZhe/YBupUyPPc9UTF1zBNjzMWL7d JDQ8k4tVuqkYH4UVVz7Alkw21gVli4angNvRXnEK+cQR1l0zcbEZP961CrbTnWlA 8sufSkLcq1gta0A7SJsj =/80f -----END PGP SIGNATURE----- --c8JyeaiReRNoiMDS--