From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXpLC-00061K-NZ for qemu-devel@nongnu.org; Mon, 22 Feb 2016 07:11:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXpLB-0006cp-7Q for qemu-devel@nongnu.org; Mon, 22 Feb 2016 07:11:50 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:49692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXpLA-0006ci-Ib for qemu-devel@nongnu.org; Mon, 22 Feb 2016 07:11:49 -0500 Date: Mon, 22 Feb 2016 23:12:27 +1100 From: David Gibson Message-ID: <20160222121227.GN2808@voom.fritz.box> References: <1456121379-13434-1-git-send-email-aik@ozlabs.ru> <20160222062631.GH2808@voom.fritz.box> <56CAF2B3.2030502@ozlabs.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qYrsQHciA3Wqs7Iv" Content-Disposition: inline In-Reply-To: <56CAF2B3.2030502@ozlabs.ru> Subject: Re: [Qemu-devel] [PATCH qemu] memory: Fix IOMMU replay base address List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy Cc: qemu-devel@nongnu.org --qYrsQHciA3Wqs7Iv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 22, 2016 at 10:36:19PM +1100, Alexey Kardashevskiy wrote: > On 02/22/2016 05:26 PM, David Gibson wrote: > >On Mon, Feb 22, 2016 at 05:09:39PM +1100, Alexey Kardashevskiy wrote: > >>Since a788f227 "memory: Allow replay of IOMMU mapping notifications" > >>when new VFIO listener is added, all existing IOMMU mappings are replay= ed. > >>However there is a problem that the base address of an IOMMU memory reg= ion > >>(IOMMU MR) is ignored which is not a problem for the existing user (whi= ch is > >>pseries) with its default 32bit DMA window starting at 0 but it is if t= here is > >>another DMA window. > >> > >>This adjusts the replaying address by mr->addr. > > > >Uh.. this doesn't look right to me. AFAICT from the existing > >implementations the 'addr' parameter to the translate function is an > >offset within the memory region, which would make the original version > >correct. >=20 > Ok, then spapr_tce_translate_iommu() needs to be fixed. Or I am missing > something here? The @addr field is definitely ignored now. I think at least one of us is missing something. In the normal AS translation path, IIUC, it will subtract the mr->addr value to give offsets which are passed to translate. It uses those offsets to find the TCE and returns a translated address. Where else the @addr be used? >=20 >=20 > > > >>Signed-off-by: Alexey Kardashevskiy > >>--- > >> memory.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >>diff --git a/memory.c b/memory.c > >>index 09041ed..377269b 100644 > >>--- a/memory.c > >>+++ b/memory.c > >>@@ -1436,7 +1436,7 @@ void memory_region_iommu_replay(MemoryRegion *mr,= Notifier *n, > >> IOMMUTLBEntry iotlb; > >> > >> for (addr =3D 0; addr < memory_region_size(mr); addr +=3D granula= rity) { > >>- iotlb =3D mr->iommu_ops->translate(mr, addr, is_write); > >>+ iotlb =3D mr->iommu_ops->translate(mr, mr->addr + addr, is_wri= te); > >> if (iotlb.perm !=3D IOMMU_NONE) { > >> n->notify(n, &iotlb); > >> } > > >=20 >=20 --=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 --qYrsQHciA3Wqs7Iv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWyvsrAAoJEGw4ysog2bOShx8P/iXNKzkblZ4dcTReuLgJRYB1 jwCu8M/B6SrGrNbEvPpwWO9a5rBfOyzlFXF2ap4BH9NjcIeT+0SIIVb/4bOFLkXD BDKhZ7daIVU2QFGQu5X3p3TgOjoNhtDLLP8QKPmf4afP5HAPDVebsYb9x1XA+/oT k3SxqRI9X4BtaYypI/6ztUM4AkIourPkWUpyK/y86q1qXAzMJK4QqYX7mQBVhSz7 wqSWqe+VC9fWVWuoAq12MuvYHwC9IXvNsMEzQlkWvKqBciG3i89HvOdxtDCV0Fbx DyGKRurvfu0QBo1hDlFQei1lq/0lmioOnh/Twzjs+XSFiSHCMS3Vxu6/vrc66XiC KtsKWGwoij1Slx/aVZMJvyVfbDb5CUC4e6ecNeJIgK5zkhGKte2rWFdEKjaxRbX1 k/zUF7xfp5YAQscdh18NQ69vUPjsPIceEqm8/UfB3n9vmEjSrs5N/145n57UYdye pok9h5TN6ZV8eKW5O59Xiuko7G1gMWQ2p0A8Szx3B2rs6eybsb1E2jldVzZlzB8e nXXql6E+5dBKqNVCPD6uHV4YhrqXHaa2YMyFa4n5yrc27zQ9FFdqkZmVpReqOHef 3pf9CgfYplwjLWK3u+n0n5WlsmINu+2fOwexLaGCzE316UqOUKdfTJdSspIEAW6p QW6P6uDFUhu2o1ux30bf =kg8J -----END PGP SIGNATURE----- --qYrsQHciA3Wqs7Iv--