public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* Sharing a page of memory between the guest and host
@ 2008-03-05 23:07 Cam Macdonell
  2008-03-06  2:09 ` Anthony Liguori
  0 siblings, 1 reply; 4+ messages in thread
From: Cam Macdonell @ 2008-03-05 23:07 UTC (permalink / raw)
  To: kvm-devel


Hello,

Is it possible to share a memory (a page perhaps) between the host and 
guest?  More precisely, could a host and guest share a memory-mapped 
file?  If one were crazy enough to want to do this, where should they 
look first?

Thanks,
Cam

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Sharing a page of memory between the guest and host
  2008-03-05 23:07 Sharing a page of memory between the guest and host Cam Macdonell
@ 2008-03-06  2:09 ` Anthony Liguori
  2008-03-06 16:13   ` Cam Macdonell
  2008-03-12 23:36   ` Cam Macdonell
  0 siblings, 2 replies; 4+ messages in thread
From: Anthony Liguori @ 2008-03-06  2:09 UTC (permalink / raw)
  To: Cam Macdonell; +Cc: kvm-devel

Cam Macdonell wrote:
> Hello,
>
> Is it possible to share a memory (a page perhaps) between the host and 
> guest?

Yes, the host always has access to all of the guests memory.  All of the 
virtio drivers depend on this fact.  With KVM, the userspace (in this 
case, QEMU), just tells the kernel about a virtual address region and 
the kernel uses that region of virtual memory for the guest's physical 
memory.  Whatever you (as userspace) maps into that region is totally up 
to you.

>   More precisely, could a host and guest share a memory-mapped 
> file?

It will be a lot easier once we have MMU notifiers upstream.  You'll be 
able to simply mmap(MAP_FIXED) a file into the guest's physical address 
space even while it's running.  For now, you have to setup these 
mappings before the VM starts.

>   If one were crazy enough to want to do this, where should they 
> look first?
>   

If you look at the -mem-file implementation in the latest git, you'll 
see that all the guest's memory can be an mmap()'d file.

Regards,

Anthony Liguori

> Thanks,
> Cam
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> kvm-devel mailing list
> kvm-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/kvm-devel
>   


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Sharing a page of memory between the guest and host
  2008-03-06  2:09 ` Anthony Liguori
@ 2008-03-06 16:13   ` Cam Macdonell
  2008-03-12 23:36   ` Cam Macdonell
  1 sibling, 0 replies; 4+ messages in thread
From: Cam Macdonell @ 2008-03-06 16:13 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: kvm-devel

Anthony Liguori wrote:
> Cam Macdonell wrote:
>> Hello,
>>
>> Is it possible to share a memory (a page perhaps) between the host and 
>> guest?
> 
> Yes, the host always has access to all of the guests memory.  All of the 
> virtio drivers depend on this fact.  With KVM, the userspace (in this 
> case, QEMU), just tells the kernel about a virtual address region and 
> the kernel uses that region of virtual memory for the guest's physical 
> memory.  Whatever you (as userspace) maps into that region is totally up 
> to you.
> 
>>   More precisely, could a host and guest share a memory-mapped file?
> 
> It will be a lot easier once we have MMU notifiers upstream.  You'll be 
> able to simply mmap(MAP_FIXED) a file into the guest's physical address 
> space even while it's running.  For now, you have to setup these 
> mappings before the VM starts.
> 
>>   If one were crazy enough to want to do this, where should they look 
>> first?
>>   
> 
> If you look at the -mem-file implementation in the latest git, you'll 
> see that all the guest's memory can be an mmap()'d file.

Hi,

Where is that implementation? I searched for mem-file, but couldn't find it.

Thanks,
Cam

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Sharing a page of memory between the guest and host
  2008-03-06  2:09 ` Anthony Liguori
  2008-03-06 16:13   ` Cam Macdonell
@ 2008-03-12 23:36   ` Cam Macdonell
  1 sibling, 0 replies; 4+ messages in thread
From: Cam Macdonell @ 2008-03-12 23:36 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: kvm-devel

Anthony Liguori wrote:
> Cam Macdonell wrote:
>> Hello,
>>
>> Is it possible to share a memory (a page perhaps) between the host and 
>> guest?
> 
> Yes, the host always has access to all of the guests memory.  All of the 
> virtio drivers depend on this fact.  With KVM, the userspace (in this 
> case, QEMU), just tells the kernel about a virtual address region and 
> the kernel uses that region of virtual memory for the guest's physical 
> memory.  Whatever you (as userspace) maps into that region is totally up 
> to you.
> 
>>   More precisely, could a host and guest share a memory-mapped file?
> 
> It will be a lot easier once we have MMU notifiers upstream.  You'll be 
> able to simply mmap(MAP_FIXED) a file into the guest's physical address 
> space even while it's running.  For now, you have to setup these 
> mappings before the VM starts.
> 
>>   If one were crazy enough to want to do this, where should they look 
>> first?
>>   
> 
> If you look at the -mem-file implementation in the latest git, you'll 
> see that all the guest's memory can be an mmap()'d file.

Hi Anthony,

In setting up the guest memory to share a page, I need to make the 
kernel aware of that page.  Is the best way to do this through a little 
virtio-like PCI device or is there an easier to get dynamic info into 
the guest kernel?

Also, is the mem-file implementation in a specific branch of the latest 
GIT or is it within the main branch somewhere, I've been unable to find it?

Thanks a bunch,
Cam

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-03-12 23:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-05 23:07 Sharing a page of memory between the guest and host Cam Macdonell
2008-03-06  2:09 ` Anthony Liguori
2008-03-06 16:13   ` Cam Macdonell
2008-03-12 23:36   ` Cam Macdonell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox