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/
Home Products Support Community News


Re: [Xen-devel] The mfn of the frame, that holds a mlock-ed PV domU user

To: Joanna Rutkowska <joanna@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] The mfn of the frame, that holds a mlock-ed PV domU usermode page, can change
From: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Date: Mon, 12 Apr 2010 13:39:43 -0700
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx, Rafal Wojtczuk <rafal@xxxxxxxxxxxxxxxxxxxxxx>, qubes-devel@xxxxxxxxxxxxxxxx
Delivery-date: Mon, 12 Apr 2010 13:40:38 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4BC380E2.8060605@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20100412185454.GC3671@xxxxxxxxxxxxxxxxxxx> <4BC37C32.1060805@xxxxxxxx> <4BC380E2.8060605@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20100330 Fedora/3.0.4-1.fc12 Lightning/1.0b2pre Thunderbird/3.0.4
On 04/12/2010 01:21 PM, Joanna Rutkowska wrote:
> On 04/12/2010 10:01 PM, Jeremy Fitzhardinge wrote:
>> Why is it necessary to map usermode pages?  It just seems like asking
>> for trouble.  Why not make it so that the domU X server gets the memory
>> from the kernel (via some kind of driver), and then map that through to
>> dom0?
> Because we want to avoid modifying Xorg sources -- it normally allocates
> its composition buffers using malloc, and if we wanted to make it using
> some kernel allocated memory (by our custom driver) we would need to
> patch the Xorg, which we obviously wanted to avoid...

The referenced code doesn't do that; it allocates some memory with with
mmap, mlocks it, uses /proc/u2mfn to get the mfn then pokes it into xenbus.

But I assume you have other code which wants to grant through the
Xorg-allocated framebufer.  That complicates things a bit, but you could
still add a device (no /proc files, please) with an ioctl which:

   1. takes a range of usermode addresses
   2. increments the page refcount for those pages
   3. returns the mfns for those pages

That will prevent the pages from being migrated while you're referring
to their mfns.  You need to add something to explicitly decrement the
refcount to prevent a memory leak, presumably at the time you tear down
the mapping in dom0.  Ideally you'd arrange to do that triggered off
unmap of the memory range (by isolating the pages in their own new vma)
so that it all gets cleaned up on process exit.


Xen-devel mailing list