On Fri, 2007-08-10 at 09:32 -0500, Anthony Liguori wrote:
> Gregory Haskins wrote:
> > Hi All,
> >   I am working on some PV stuff and had some questions about the ability
> > to share memory across the Guest/Host boundary.
> >
> > It seems that most examples of how to do this always involve starting
> > with a *page, converting it to a gfn via page_to_gfn(), and using that
> > as a gpa to pass across the boundary.
> >   
> 
> Do you mean page_to_pfn?  I assume you're talking about a page within 
> the guest right?

Er, ya.  Sorry...up too late last night ;)

> 
> > I understand that this method avoids a software traipse through the
> > page-walker, so it's nice.  What I can't quite figure out is what are
> > the other types of memory (if any) that can be passed across.
> >
> > For instance, is a pointer from kmalloc() considered a gpa, a gva,
> > neither?
> 
> gpa = guest physical address.  It's a pa or a pfn << PAGE_SHIFT.
> 
> gva = guest virtual address.  It's returned from pretty much anything 
> that allocates memory (kmalloc for instance).  This is all within the 
> guest of course.
> 
> >   Or are gva's only pointers that come from guest-userspace,
> > etc.  Is it possible to pass something like a skb->data pointer (I
> > understand that I may have to run the page-walker for some of these)?
> >   
> 
> Yes, you can pass through any gva.  There are couple of things to be 
> aware of though.  When passing a gva, you have to be sure that the gva 
> is actually mapped in memory as KVM cannot cause Linux to fault in a 
> page.

Cool!  Ya, I totally understand and agree that it has to be "DMA" class
memory that is mapped and pinned in guest context.  IIUC you basically
need to follow the same rules as you would for a DMA based device in a
bare-metal scenario.

>   Also, for something like skb->data, you should probably just pass 
> the gpa since they'll usually fall within a single page anyway.

Hmm...good point.

> 
> > If so, how would I do this:  E.g. can I just pass the pointer, and then
> > do gva_to_hpa() on the host?  Or do I need to prep the pointer before
> > sending it?
> >   
> 
> There's no need to prep provided that you know the va is mapped into 
> memory in the guest.
> 

Thanks Anthony!  Very helpful indeed and I appreciate the explanation.

On this topic:  I know there has been talk going on of giving each VM
its own linux va context.  IIUC, when that happens we wouldn't need the
gva_to_hpa type functions, right?  We could use things like
copy_to_user(), etc?  Out of curiosity, what's the status of that
project?


-Greg


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to