From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXZcY-0008Gt-Nn for qemu-devel@nongnu.org; Wed, 01 May 2013 12:11:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UXZcX-00015Y-3x for qemu-devel@nongnu.org; Wed, 01 May 2013 12:11:06 -0400 Received: from mail-ye0-f169.google.com ([209.85.213.169]:39469) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXZcX-00015S-0F for qemu-devel@nongnu.org; Wed, 01 May 2013 12:11:05 -0400 Received: by mail-ye0-f169.google.com with SMTP id q1so300074yen.0 for ; Wed, 01 May 2013 09:11:04 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <51813E87.2030704@redhat.com> Date: Wed, 01 May 2013 18:10:47 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <20130501043524.GO20202@truffula.fritz.box> In-Reply-To: <20130501043524.GO20202@truffula.fritz.box> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 09/17] memory: iommu support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: aik@truffula.fritz.box, qemu-devel@nongnu.org -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Il 01/05/2013 06:35, David Gibson ha scritto: >> From: Avi Kivity >> >> Add a new memory region type that translates addresses it is >> given, then forwards them to a target address space. This is >> similar to an alias, except that the mapping is more flexible >> than a linear translation and trucation, and also less efficient >> since the translation happens at runtime. >> >> The implementation uses an AddressSpace mapping the target region >> to avoid hierarchical dispatch all the way to the resolved >> region; only iommu regions are looked up dynamically. >> >> Signed-off-by: Avi Kivity [Modified to put >> translation in address_space_translate - Paolo] Signed-off-by: >> Paolo Bonzini --- exec.c | >> 35 +++++++++++++++++++++++++++++------ include/exec/memory.h | >> 44 ++++++++++++++++++++++++++++++++++++++++++++ memory.c >> | 28 ++++++++++++++++++++++++++++ 3 files changed, 101 >> insertions(+), 6 deletions(-) > > [snip] >> +void memory_region_init_iommu(MemoryRegion *mr, + >> MemoryRegionIOMMUOps *ops, + >> MemoryRegion *target, + const char >> *name, + uint64_t size) +{ + >> memory_region_init(mr, name, size); + mr->ops = NULL; + >> mr->iommu_ops = ops, + mr->opaque = mr; + mr->terminates = >> true; /* then re-forwards */ + mr->destructor = >> memory_region_destructor_iommu; + mr->iommu_target_as = >> g_new(AddressSpace, 1); + >> address_space_init(mr->iommu_target_as, target); > > Since IOMMUs are very likely to share a target AS (in fact, it > will nearly always be system memory), it seems odd to me to > construct new AddressSpace objects for each one, rather than just > giving the AddressSpace as the parameter to > memory_region_init_iommu. > I think the problem is that we do not have reference counting, and this makes it simpler to manage the lifetime. It can be changed later. Paolo -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJRgT6GAAoJEBvWZb6bTYbyk/cP/RCHjFrtXYas+TLti8vcbCS1 zCUGnURgNqKxI4529E9VGF4PlO6/uxDP/mpNgDx7FCkMyA6bNL6fxw7RhvWyKFjU xvZt6l7HYVOxbuNVAraZ4JmQ+fnvgyxJn1djMKNdGKNuRdpXj6b2NC+xyw8rSSc2 bIR6FT0piAlFP+kXiNFyf3cIZzT84qVX1tqphCRov7jvWyYG8Zv5VHpEEjaY7fJS LEJFQ4ZfjM94RAekhZ7GkGmmlh9vfTplKz0G+0/EOYcaWBNwd7bKjGf6hWNtLb3z 3chtMKyODe8JRR/FuWuLx0GDZzvKZOE9yRGHerhL0aDCMviNKILUTnES3twe82j9 F8ywYO4CnkdKRIzKXXDTd8hZkgzF60fWzMvtvjOg6oXHJFyNoXRLhD23sZsTFaMi q+mk7JiPfXrvjrZcUlQ4YwN7gv9gkZ+2JO1di/R9Xq62aqYBLke9Fwke7fdX+qbR RB7coXgfExheRJdyWB56Lqr9m2KAtnW7T6ISR1G/nV0yr+ye1N9LifUkCAg4MHa8 ANsMMA6NbwmwtqJ9DDqzH+RkK7ZzCzq/IkYGeEial/sUnxXLggu6LanyahTMun49 ZmJDbEUWVAbrA4bkbQ1XHM6B2EFLg//wen7uSdIR+UZKgjkhxpB+PKiLppvPyXW1 5LuT1XZmghaeE3nD/i3A =GcNo -----END PGP SIGNATURE-----