WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] Mapping another domain's user memory

On Jan 31, 2008, at 11:16 AM, Derek Murray wrote:

On Jan 31, 2008 2:57 PM, Michael Abd-El-Malek <mabdelmalek@xxxxxxx> wrote:
I tried to do that by first getting a grant for the user-space memory
in the source domain as follows:

       page_start = user_buf;
       buffer_mfn = virt_to_mfn(page_start);
gnttab_grant_foreign_access_ref(grant_ref, info->dev- >otherend_id,
buffer_mfn, 0);

But the virt_to_mfn call asserted, in include/asm-x86_64/mach-xen/ asm/
maddr.h:pfn_to_mfn.
The assertion that failed was: BUG_ON(end_pfn && pfn >= end_pfn);

You have another problem here, because virt_to_mfn (and virt_to_page
etc.) operate on kernel virtual addresses, where converting to a
physical address effectively just involves subtracting an offset. User
virtual addresses are handled differently, and you'll have to walk the
page table to find the PTE and from that obtain an MFN.

Thanks for your help Derek. Fortunately I didn't have to muck around with the page tables. get_user_pages already does this. So I called that function to get the relevant pages for the user pointer, kmap'ed those pages, got the virtual address using virt_to_mfn, and Xen's grants worked.

Cheers,
Mike

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>