From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LqsoQ-0005Z6-Ha for qemu-devel@nongnu.org; Mon, 06 Apr 2009 13:40:46 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LqsoL-0005XM-IG for qemu-devel@nongnu.org; Mon, 06 Apr 2009 13:40:45 -0400 Received: from [199.232.76.173] (port=43528 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LqsoL-0005XJ-CO for qemu-devel@nongnu.org; Mon, 06 Apr 2009 13:40:41 -0400 Received: from mx2.redhat.com ([66.187.237.31]:48510) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LqsoL-0005Wc-0K for qemu-devel@nongnu.org; Mon, 06 Apr 2009 13:40:41 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n36Hecxn000612 for ; Mon, 6 Apr 2009 13:40:38 -0400 Message-ID: <49DA3EBC.5050009@redhat.com> Date: Mon, 06 Apr 2009 20:41:16 +0300 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] Newbie: How to implement iommu? References: <1239033090.1975.78.camel@nibbler.dlib.indiana.edu> In-Reply-To: <1239033090.1975.78.camel@nibbler.dlib.indiana.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Brian Wheeler wrote: > I've been going through the source (and the list archives) and I must be > missing something obvious. > Many things in qemu are not obvious and are easy to miss, so you may drop this disclaimer in the future, if you like. > I need to translate an address passed to > cpu_physical_memory_{read,write} via an IOMMU. I've been told there's a > dma api, but I cannot find any documentation about it, nor can I find an > obvious user of it. > The core dma api is cpu_physical_memory_{map,unmap}(), in exec.c. One user is hw/ide.c, through the helpers in dma-helpers.c. > So how do I catch cpu_physical_memory_{read,write} calls and put my > address translation in there? > I guess these should be replaced by a pci_memory_{read,write}() (or equivalents for other busses) which would do the translation. Given that the translation changes depending on where you are in the system topology, you'd need to pass an identifier representing that (for pci, your PCIDevice pointer). -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.