kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cam Macdonell <cam@cs.ualberta.ca>
To: Avi Kivity <avi@redhat.com>
Cc: Stephen Donnelly <sfdonnelly@gmail.com>, kvm@vger.kernel.org
Subject: Re: R/W HG memory mappings with kvm?
Date: Wed, 08 Jul 2009 15:45:43 -0600	[thread overview]
Message-ID: <4A551387.3000702@cs.ualberta.ca> (raw)
In-Reply-To: <4A54225F.1050703@redhat.com>

Avi Kivity wrote:
> On 07/08/2009 01:23 AM, Stephen Donnelly wrote:
>>
>>>> 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).
>>>      
>>
>> So host memory is exported as a PCI_BAR to the guest via
>> cpu_register_physical_memory(). It looks like the code has to
>> explicitly manage marking pages dirty and synchronising at appropriate
>> times. Is the coherency problem bidirectional, e.g. writes from either
>> host or guest to the shared memory need to mark pages dirty, and
>> ensure sync is called before the other side reads those areas?
>>    
> 
> Shared memory is fully coherent.  You can use the ordinary x86 bus lock 
> operations for concurrent read-modify-write access, and the memory 
> barrier instructions to prevent reordering.  Just like ordinary shared 
> memory.
> 
>>>> 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.
>>>      
>>
>> I will look into the vga code and see if I get inspired. The 'copied'
>> driver sounds interesting, the code is not in kvm git?
>>    
> 
> (copied) means Cam was copied (cc'ed) on the email, not the name of the 
> driver.  It hasn't been merged but copies (of the driver, not Cam) are 
> floating around on the Internet.

Hi Stephen,

Here is the latest patch that supports interrupts.  I am currently 
working on a broadcast mechanism that should be ready fairly soon.

http://patchwork.kernel.org/patch/22368/

I have some test scripts that can demonstrate how to use the memory 
between guest/host and guest/guest.  Let me know if you would like me to 
send them to you.

Cheers,
Cam

> 
> The relevant parts of cirrus_vga.c are:
> 
> static void cirrus_pci_lfb_map(PCIDevice *d, int region_num,
>                                uint32_t addr, uint32_t size, int type)
> {
> 
> ...
> 
>     /* XXX: add byte swapping apertures */
>     cpu_register_physical_memory(addr, s->vga.vram_size,
>                                  s->cirrus_linear_io_addr);
> 
> This function is called whenever the guest updates the BAR.
> 

  parent reply	other threads:[~2009-07-08 22:16 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-05 22:41 R/W HG memory mappings with kvm? Stephen Donnelly
2009-07-06  7:38 ` Avi Kivity
2009-07-07 22:23   ` Stephen Donnelly
2009-07-08  4:36     ` Avi Kivity
2009-07-08 21:33       ` Stephen Donnelly
2009-07-09  8:10         ` Avi Kivity
2009-07-08 21:45       ` Cam Macdonell [this message]
2009-07-08 22:01         ` Stephen Donnelly
2009-07-09  6:01           ` Cam Macdonell
2009-07-09 22:38             ` Stephen Donnelly
2009-07-10 17:03               ` Cam Macdonell
2009-07-12 21:28                 ` Stephen Donnelly
2009-07-14 22:25                   ` [PATCH] Support shared memory device PCI device Cam Macdonell
     [not found]             ` <5f370d430907262256rd7f9fdalfbbec1f9492ce86@mail.gmail.com>
2009-07-27 14:48               ` R/W HG memory mappings with kvm? Cam Macdonell
2009-07-27 21:32                 ` Stephen Donnelly
2009-07-28  8:54                   ` Avi Kivity
2009-07-28 23:06                     ` Stephen Donnelly
2009-08-13  4:07                       ` Stephen Donnelly
2009-08-19 12:14                         ` Avi Kivity
2009-08-23 21:59                           ` Stephen Donnelly
2009-08-24  4:55                             ` Avi Kivity
2009-08-26 10:22                               ` Avi Kivity
2009-08-27  2:39                                 ` Stephen Donnelly
2009-08-27  2:34                               ` Stephen Donnelly
2009-08-27  4:08                                 ` Avi Kivity
2009-08-30 22:33                                   ` Stephen Donnelly
2009-08-31  8:44                                     ` Avi Kivity
2009-08-31 21:13                                       ` Stephen Donnelly
2009-09-09 12:50                                         ` Avi Kivity
2009-07-29 23:52                     ` Cam Macdonell
2009-07-30  9:31                       ` Avi Kivity
2009-09-28 18:27 Tsuyoshi Ozawa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A551387.3000702@cs.ualberta.ca \
    --to=cam@cs.ualberta.ca \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=sfdonnelly@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).