From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: R/W HG memory mappings with kvm? Date: Tue, 28 Jul 2009 11:54:11 +0300 Message-ID: <4A6EBCB3.4080804@redhat.com> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Cam Macdonell , "kvm@vger.kernel.org list" To: Stephen Donnelly Return-path: Received: from mx2.redhat.com ([66.187.237.31]:58332 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750743AbZG1Iti (ORCPT ); Tue, 28 Jul 2009 04:49:38 -0400 In-Reply-To: <5f370d430907271432y5283c2cat7673efeed0febe20@mail.gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: 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. -- error compiling committee.c: too many arguments to function