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

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

  • To: "Michael Abd-El-Malek" <mabdelmalek@xxxxxxx>
  • From: "Derek Murray" <derek.murray@xxxxxxxxx>
  • Date: Thu, 31 Jan 2008 16:16:32 +0000
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 06 Feb 2008 02:39:50 -0800
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=jKqYuusjAA/nn+u15Ejrk1hu8BABgjo0oa7vXJY5/xTEWGbU+3klVMDWjpZHCrrtjFxFMz5m3H2I7mlElaxJBReKITsY06/7OC1hP1Wcqhene4BBQltUIDdgr7rThUaTHe40e+c0gS6uvUPNIcQzciBt40k90gAAurZ4u2mQGEM=
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

Hi Mike,

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.

To respond to Daniel's point, from my reading of the code, the grant
table entry takes a "GMFN", which is equivalent to an MFN on PV guests
without shadow translation. Therefore it shouldn't be necessary to
translate this to a pseudo-physical frame number.

> So a few questions:
> 1) is it even possible to map a domain's user-space page into another
> domain?

I don't see any problem in principle, though you'll have to make sure
that the page is locked in memory.

> 3) does the blktap driver do something similar? I tried looking at the
> blktap driver, because it looked like it might help.  But I'm new to
> the Xen memory management code so it was a bit difficult to follow.

blktap maps memory that was granted by another domain's kernel (in the
blkfront driver) into user-space. Therefore, on the destination side,
this is probably more complicated than you need. However, if you did
want to map the grant into user-space, you could use gntdev, which
employs the same mechanism as blktap.


Derek Murray.

Xen-devel mailing list



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