ia64/xen-unstable

changeset 17256:6ac99b961bff

x86: stub domains and page ownership for mapping in dom0

In the case of an ioemu stubdomain with SDL or vnc server running in
dom0, we want to have the stubdomain expose the HVM guest's video RAM
through PVFB.

However, to map the pages from dom0, xenfb uses xc_map_foreign_pages
with the stubdomain ID as domid (since that is what is advertised in
the PVFB protocol, and needed for other parts of the protocol), and
thus get_page_from_l1e() complains because the stubdomain is not the
owner of the pages. In such case, this patch checks that the
stubdomain has privileges on the actual owner of the pages, and then
accept the mapping.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 18 16:15:24 2008 +0000 (2008-03-18)
parents 4b157affc08f
children df89656a4b94
files xen/arch/x86/mm.c
line diff
     1.1 --- a/xen/arch/x86/mm.c	Tue Mar 18 16:05:24 2008 +0000
     1.2 +++ b/xen/arch/x86/mm.c	Tue Mar 18 16:15:24 2008 +0000
     1.3 @@ -645,6 +645,7 @@ get_page_from_l1e(
     1.4      struct page_info *page = mfn_to_page(mfn);
     1.5      uint32_t l1f = l1e_get_flags(l1e);
     1.6      struct vcpu *curr = current;
     1.7 +    struct domain *owner = page_get_owner(page);
     1.8      int okay;
     1.9  
    1.10      if ( !(l1f & _PAGE_PRESENT) )
    1.11 @@ -673,6 +674,16 @@ get_page_from_l1e(
    1.12          return 1;
    1.13      }
    1.14  
    1.15 +    /*
    1.16 +     * Let privileged domains transfer the right to map their target
    1.17 +     * domain's pages. This is used to allow stub-domain pvfb export to dom0,
    1.18 +     * until pvfb supports granted mappings. At that time this minor hack
    1.19 +     * can go away.
    1.20 +     */
    1.21 +    if ( unlikely(d != owner) && (owner != NULL) &&
    1.22 +         (d != curr->domain) && IS_PRIV_FOR(d, owner) )
    1.23 +        d = owner;
    1.24 +
    1.25      /* Foreign mappings into guests in shadow external mode don't
    1.26       * contribute to writeable mapping refcounts.  (This allows the
    1.27       * qemu-dm helper process in dom0 to map the domain's memory without