From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYB9R-0006hr-2k for qemu-devel@nongnu.org; Tue, 23 Feb 2016 06:29:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYB9N-00039E-Qo for qemu-devel@nongnu.org; Tue, 23 Feb 2016 06:29:09 -0500 Received: from ozlabs.org ([103.22.144.67]:48760) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYB9N-00038z-Fp for qemu-devel@nongnu.org; Tue, 23 Feb 2016 06:29:05 -0500 Date: Tue, 23 Feb 2016 22:25:58 +1100 From: David Gibson Message-ID: <20160223112558.GX2808@voom.fritz.box> References: <1456121379-13434-1-git-send-email-aik@ozlabs.ru> <20160222062631.GH2808@voom.fritz.box> <56CAF2B3.2030502@ozlabs.ru> <20160222121227.GN2808@voom.fritz.box> <56CBBFD7.3050806@ozlabs.ru> <20160223062056.GU2808@voom.fritz.box> <56CC1FA3.5020003@ozlabs.ru> <56CC2CE9.6030605@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="SqGHvGqRphKoTacN" Content-Disposition: inline In-Reply-To: <56CC2CE9.6030605@redhat.com> 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: Paolo Bonzini Cc: Alexey Kardashevskiy , qemu-devel@nongnu.org --SqGHvGqRphKoTacN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Feb 23, 2016 at 10:56:57AM +0100, Paolo Bonzini wrote: >=20 >=20 > On 23/02/2016 10:00, Alexey Kardashevskiy wrote: > >>> > >>> tce =3D tcet->table[addr >> tcet->page_shift]; > >>> - ret.iova =3D addr & page_mask; > >>> + ret.iova =3D (addr + iommu->addr) & page_mask; > >>> ret.translated_addr =3D tce & page_mask; > >> > >> I wondered about that change, but I'd have to look closer to see if > >> the iova field here is expected to be relative to the MR as well. It > >> would be oddly inconsistent if it wasn't. > >=20 > > It is relative and it does not make sense as there is no source MR/AS in > > iotlb (only target AS) so there is no use in such iova. >=20 > ret.iova should be relative to the source AS (i.e. even if a 32-bit > IOMMU region translates between 4GB and 8GB, ret.iova should have bits > 32-63 set to 0). Uh.. relative to the source AS, or the source MR? At the moment spapr implements it relative to the MR.. which seems to match your example. > So there is a problem in vfio_iommu_map_notify: >=20 > ret =3D vfio_dma_map(container, iotlb->iova, > iotlb->addr_mask + 1, vaddr, > !(iotlb->perm & IOMMU_WO) || mr->readonly); Ah.. yeah.. this needs the address relative to the AS, not the MR > I think that, in vfio_listener_region_add, the iova variable should be > stored in VFIOGuestIOMMU for use in vfio_iommu_map_notify. Hmm, seems a bit clunky, though I guess it's safe due to the BQL. > ret.translated_addr should be relative to the target AS, which VFIO > assumes to be address_space_memory. Right, and as far as I can tell that is the case. --=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 --SqGHvGqRphKoTacN Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWzEHGAAoJEGw4ysog2bOSU8IP/1VG4CO7ACollI0Bri+Ke4nv fOyNv+HK6EpVgXxqFLmPkbxsVXFt7DZh8jQWrWU4klDxALIRhNA/Fy/Ic+Utb72n bK/wQYZvGLk3jJWGo6iv7lBPcv9wJFLnAvdwbanNOkhlGShoDsl3BqKTECCquBkv OtPpPqiycRVjP3zQvW7Jsd6tcGN34LCQP+pC8FKc4UIBCi6Q2ysPcqvTQhUnhi+a 9FHfSWZCgVwhT6xq+NM9yw9Cb7rPqwOODY7qO7b5wgcyX6ukcN7ST456CmZKvJPB vIL75FemTx0UWV+AKWHU22HlEKirEe6NXHdrclggf6UWk+X9ljl/Hjh3S+OQXHc+ 5W/r6Wpa1zc1rEdO3EWIiqtL1c1V8KQiKZsslJB+T4PW14h647hL7fau28KNC+gY etTMgpzBaSjoGnRqzYhqdn6DXw4/26PsPSTP3jMyQoYbySlj9oP3pt2EPlthSnO8 b3QGBvDg+hxG7Qs4un0N3M05FyfFieVOjYzaYrJ6STn5KxV/EpmkYGkpJ+GJAc71 mzgURzOKrHfuZD24JhjL4zxq+LRyrDDp62SpEV5ko+SIjQbmiMHsBUkxoLcrztW8 oOM/Iz8FppblZeM/j27VpPbGyjtOSl9VQ5vzR8GfsueRWp0pzvRnA5BslehY86+d iNkMjgALswpnGa+qNe9D =JPX7 -----END PGP SIGNATURE----- --SqGHvGqRphKoTacN--