From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zehox-0000gN-8R for qemu-devel@nongnu.org; Wed, 23 Sep 2015 07:02:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zehos-0002D8-Np for qemu-devel@nongnu.org; Wed, 23 Sep 2015 07:02:43 -0400 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> <20150917233157.GC2547@voom.fritz.box> From: Thomas Huth Message-ID: <560286C8.3010903@redhat.com> Date: Wed, 23 Sep 2015 13:02:32 +0200 MIME-Version: 1.0 In-Reply-To: <20150917233157.GC2547@voom.fritz.box> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="e4aI32HWMUqbL8tcbPSb4tsd2VMD212qH" 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: David Gibson , Alex Williamson Cc: lvivier@redhat.com, aik@ozlabs.ru, gwshan@linux.vnet.ibm.com, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, pbonzini@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --e4aI32HWMUqbL8tcbPSb4tsd2VMD212qH Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 18/09/15 01:31, David Gibson wrote: > 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 mappin= gs >>> in sync with the guest memory image assumes that if a guest IOMMU >>> appears, then it has no existing mappings. >>> >>> 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. >>> >>> 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. >>> >>> Signed-off-by: David Gibson >>> --- >>> hw/vfio/common.c | 34 +++++++++++++++++++--------------- >>> 1 file changed, 19 insertions(+), 15 deletions(-) >>> >>> 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); >> >> return (hwaddr)1 << (ffsl(container->iommu_data.iova_pgsizes) - 1; >=20 > 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. Maybe use ffsll instead of ffsl, in case the code ever runs on a 32-bit host instead of a 64-bit host ? Thomas --e4aI32HWMUqbL8tcbPSb4tsd2VMD212qH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJWAobIAAoJEC7Z13T+cC211pIP/AkcyrUbiaNP5SKmlCt1Zbe5 zZlyZSacDqP8wTjImCHPy75msUiety009yT7UChNfQ3WGncz+4/4DjRPNzjvmKHp WiuPqCs8zmXRqq7hT7XmYqebnwOgllHvjjS/f38tw17x14maapNfA7IniMLS01eA a7ybcQBuvp//RIOPtSrQ3oOHfi2Ui+IpIU3Ah6Fo1TkxCsee4K5jyzApjS+WmYeQ pyo45T2J61dRrjjTFp/KJ0GFJobwZ5QSl1emZK5bpJiOKDd35+E09qiiAJYSxzXg WEAjNZ05C8s7gyXgPPdjFBUWx4hE1qs3ISCyGgdM/Wxof/h/3xFcP7w+0XZZPgPM PtPEDLCXXoekcJ9uEc05S/vtnT7IynPyNbN+uDOoS53E3R+RgLLj1ESZIe/+H2oP ig1mFi6DkufnpHQgHz7qwZ54VHuuqvzDySzHgIuBfh4yOa935X0B68WkQlw6Ojuw oz2L5tjpDhUSvOyHlJIA2o74BwploY0/iPqDPYOkdgUmqJqUSoou2lhJfyn30qRl G2audOFBEaNlI1Ap+aXVR3a739pR7sbukPVNGJ5Smkgp3/DA4EV+YotKRYrT3KV6 M+pj+AZCUbiJv32BQ2wQD2bnGu6Zy+DejMUFbRbVi9NsE75YoaYG86Z76eiL1LSn W1aq4pKyDIlYEwYZmQT1 =8LUI -----END PGP SIGNATURE----- --e4aI32HWMUqbL8tcbPSb4tsd2VMD212qH--