[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] About sharing pages between Xen and guest kernel



>>> On 13.11.14 at 00:52, <amaro@xxxxxxxxxx> wrote:
> Hello,
> 
> I am trying to set up a shared page between the hypervisor and a Linux guest 
> kernel. In Xen I am doing:
> 
> void *ptr = alloc_xenheap_page();
> share_xen_page_with_guest(virt_to_page(ptr), current->domain, 
> XENSHARE_writable);
> unsigned int mfn = virt_to_mfn(ptr);
> 
> And my plan was to pass the mfn to the guest kernel and retrieve the pfn 
> with mfn_to_pfn(). However, this returned ~0. 
> 
> So I took a look at share_xen_page_with_guest() and I noticed it calls 
> set_gpfn_from_mfn(mfn, INVALID_M2P_ENTRY), 
> where INVALID_M2P_ENTRY = ~0.
> 
> My questions are:
>       1. Do I have to call set_gpfn_from_mfn() after calling 
> share_xen_page_with_guest() in the hypervisor?
>       2. If yes, what gpfn should I use? I am thinking I could allocate a 
> page in 
> the guest, and retrieve the pfn with page_to_pfn(), 
>       and then pass that to the hypervisor. But I donât know if I am 
> overcomplicating things.

No, that wouldn't be correct (as is implied by 2). Instead you want
to map the page based on its MFN (i.e. potentially without even
establishing a PFN for it). But I suppose you looked at other
examples in the source code, and you should have realized that
this isn't really meant to be used for arbitrary memory sharing.
Perhaps xentrace's map_tbufs() would be the closest reference to
use.

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.