From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: R/W HG memory mappings with kvm? Date: Mon, 06 Jul 2009 10:38:24 +0300 Message-ID: <4A51A9F0.7000909@redhat.com> References: <5f370d430907051541o752d3dbag80d5cb251e5e4d00@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, Cam Macdonell To: Stephen Donnelly Return-path: Received: from mx2.redhat.com ([66.187.237.31]:56934 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750877AbZGFHgH (ORCPT ); Mon, 6 Jul 2009 03:36:07 -0400 In-Reply-To: <5f370d430907051541o752d3dbag80d5cb251e5e4d00@mail.gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: On 07/06/2009 01:41 AM, Stephen Donnelly wrote: > I am looking at how to do memory mapped IO between host and guests > under kvm. I expect to use the PCI emulation layer to present a PCI > device to the guest. > > I see virtio_pci uses cpu_physical_memory_map() which provides either > read or write mappings and notes "Use only for reads OR writes - not > for read-modify-write operations." > Right, these are for unidirectional transient DMA. > Is there an alternative method that allows large (Several MB) > persistent hg memory mappings that are r/w? I would only be using this > under kvm, not kqemu or plain qemu. > All of guest memory is permanently mapped in the host. You can use accessors like cpu_physical_memory_rw() or cpu_physical_memory_map() to access it. What exactly do you need that is not provided by these accessors? > Also it appears that PCI IO memory (cpu_register_io_memory) is > provided via access functions, like the pci config space? It can also use ordinary RAM (for example, vga maps its framebuffer as a PCI BAR). > Does this > cause a page fault/vm_exit on each read or write, or is it more > efficient than that? > It depends on how you configure it. Look at the vga code (hw/vga.c, hw/cirrus_vga.c). Also Cam (copied) wrote a PCI card that provides shared memory across guests, you may want to look at that. -- error compiling committee.c: too many arguments to function