From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfR39-00019h-RV for qemu-devel@nongnu.org; Fri, 25 Sep 2015 07:20:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfR35-0001Vi-SF for qemu-devel@nongnu.org; Fri, 25 Sep 2015 07:20:23 -0400 References: <1443069231-14856-1-git-send-email-david@gibson.dropbear.id.au> <1443069231-14856-6-git-send-email-david@gibson.dropbear.id.au> From: Paolo Bonzini Message-ID: <56052DEC.6040500@redhat.com> Date: Fri, 25 Sep 2015 13:20:12 +0200 MIME-Version: 1.0 In-Reply-To: <1443069231-14856-6-git-send-email-david@gibson.dropbear.id.au> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit 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: David Gibson , alex.williamson@redhat.com Cc: lvivier@redhat.com, thuth@redhat.com, qemu-ppc@nongnu.org, abologna@redhat.com, qemu-devel@nongnu.org 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. > > 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 didn't > previously have an VFIO devices (and hence no host IOMMU mappings). > > 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 the > caller must specify a granularity at which to replay mappings. > > 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 (probably > 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. > > Signed-off-by: David Gibson The patch is okay, just two questions: 1) Is there a case where using the no-replay functions makes sense? 2) You could add a ->replay function to the iommu_ops to optimize it, if you want. Paolo