From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NjZO7-0005Rv-Uq for qemu-devel@nongnu.org; Mon, 22 Feb 2010 09:35:55 -0500 Received: from [199.232.76.173] (port=60588 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjZO7-0005Rn-Hq for qemu-devel@nongnu.org; Mon, 22 Feb 2010 09:35:55 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NjZO6-0004ST-61 for qemu-devel@nongnu.org; Mon, 22 Feb 2010 09:35:55 -0500 Received: from mail-gx0-f209.google.com ([209.85.217.209]:50075) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NjZO5-0004SD-Tl for qemu-devel@nongnu.org; Mon, 22 Feb 2010 09:35:54 -0500 Received: by gxk1 with SMTP id 1so179568gxk.16 for ; Mon, 22 Feb 2010 06:35:52 -0800 (PST) Message-ID: <4B829645.5020904@codemonkey.ws> Date: Mon, 22 Feb 2010 08:35:49 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] Address translation - virt->phys->ram References: <4B828DC2.3000609@collabora.co.uk> In-Reply-To: <4B828DC2.3000609@collabora.co.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ian Molton Cc: qemu-devel@nongnu.org On 02/22/2010 07:59 AM, Ian Molton wrote: > Hi folks, > > I've been updating some old patches which make use of a function to > translate guest virtual addresses into pointers into the guest RAM. > > As I understand it qemu has guest virtual and physical addresses, the > latter of which map somehow to host ram addresses. > > The function which the code had been using appears not to work under > kvm, which leads me to think that qemu doesnt emulate the MMU (or at > least not in the same manner) when it is using kvm as opposed to pure > emulation. > > If I turn off kvm, the patch works, albeit slowly. If I enable it, the > code takes the path which looks for the magic value (below). > > Is there a 'proper' way to translate guest virtual addresses into host > RAM addresses? > cpu_physical_memory_map(). But this function has some subtle characteristics. It may return a bounce buffer if you attempt to map MMIO memory. There is a limited pool of bounce buffers available so it may return NULL in the event that it cannot allocate a bounce buffer. It may also return a partial result if you're attempting to map a region that straddles multiple memory slots. Regards, Anthony Liguori