From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cam Macdonell Subject: Re: R/W HG memory mappings with kvm? Date: Wed, 29 Jul 2009 17:52:59 -0600 Message-ID: <4A70E0DB.5020200@cs.ualberta.ca> References: <5f370d430907051541o752d3dbag80d5cb251e5e4d00@mail.gmail.com> <4A51A9F0.7000909@redhat.com> <5f370d430907071523t120da246wf366dbfbbac9169b@mail.gmail.com> <4A54225F.1050703@redhat.com> <4A551387.3000702@cs.ualberta.ca> <5f370d430907081501m60064c7dp23ebd4153c9050f1@mail.gmail.com> <5f370d430907262256rd7f9fdalfbbec1f9492ce86@mail.gmail.com> <4A6DBE54.3080609@cs.ualberta.ca> <5f370d430907271432y5283c2cat7673efeed0febe20@mail.gmail.com> <4A6EBCB3.4080804@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Stephen Donnelly , "kvm@vger.kernel.org list" To: Avi Kivity Return-path: Received: from fleet.cs.ualberta.ca ([129.128.22.22]:51829 "EHLO fleet.cs.ualberta.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755245AbZG2XxH (ORCPT ); Wed, 29 Jul 2009 19:53:07 -0400 Received: from fleet.cs.ualberta.ca (localhost.localdomain [127.0.0.1]) by fleet-spampd (Postfix) with ESMTP id 8D0372806D for ; Wed, 29 Jul 2009 17:52:59 -0600 (MDT) In-Reply-To: <4A6EBCB3.4080804@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Avi Kivity wrote: > On 07/28/2009 12:32 AM, Stephen Donnelly wrote: >>>> What I don't understand is how to turn the host address returned from >>>> mmap into a ram_addr_t to pass to pci_register_bar. >>>> >>> Memory must be allocated using the qemu RAM functions. >>> >> >> That seems to be the problem. The memory cannot be allocated by >> qemu_ram_alloc, because it is coming from the mmap call. The memory is >> already allocated outside the qemu process. mmap can indicate where in >> the qemu process address space the local mapping should be, but >> mapping it 'on top' of memory allocated with qemu_ram_alloc doesn't >> seem to work (I get a BUG in gfn_to_pfn). >> > > You need a variant of qemu_ram_alloc() that accepts an fd and offset and > mmaps that. A less intrusive, but uglier, alternative is to call > qemu_ram_alloc() and them mmap(MAP_FIXED) on top of that. Hi Avi, I noticed that the region of memory being allocated for shared memory using qemu_ram_alloc gets added to the total RAM of the system (according to /proc/meminfo). I'm wondering if this is normal/OK since memory for the shared memory device (and similarly VGA RAM) is not intended to be used as regular RAM. Should memory of devices be reported as part of MemTotal or is something wrong in my use of qemu_ram_alloc()? Thanks, Cam