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] guest physical to xen machine copy?

To: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>, "Xen-Devel (E-mail)" <xen-devel@xxxxxxxxxxxxxxxxxxx>, "Tian, Kevin" <kevin.tian@xxxxxxxxx>
Subject: RE: [Xen-devel] guest physical to xen machine copy?
From: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>
Date: Mon, 29 Sep 2008 18:50:53 +0000 (GMT)
Cc:
Delivery-date: Mon, 29 Sep 2008 11:52:53 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <C50638EE.1DACF%keir.fraser@xxxxxxxxxxxxx>
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Hmmm...  gfn_to_mfn() when used as below seems to just
return the original gfn, e.g.

guest_mfn = gfn_to_mfn(current->domain,gpfn,&t);

Is this correct?  Note that current->domain is a 32-bit
paravirtualized domain and xen is 64-bit, if that matters.
(Is there a better way if one knows that the domain is
always pv?)

> Use p2m_is_ram() instead of checking individual p2m ram type

In copying the other direction (e.g. copy_page_TO_guest),
I think I need to check for t==p2m_ram_rw, right?
If so, the "Not necessarily true" comment in static
inline _gfn_to_mfn in include/asm-x86/p2m.h worries me.
Should it?

Dan

> -----Original Message-----
> From: Keir Fraser [mailto:keir.fraser@xxxxxxxxxxxxx]
> Sent: Monday, September 29, 2008 12:49 AM
> To: Dan Magenheimer; Xen-Devel (E-mail); Tian, Kevin
> Subject: Re: [Xen-devel] guest physical to xen machine copy?
>
>
> On 28/9/08 21:19, "Dan Magenheimer"
> <dan.magenheimer@xxxxxxxxxx> wrote:
>
> >> You can try gfn_to_mfn.
> >
> > Thanks!  Then if I have a page_info pointer and a gpfn, will
> > this code work for copying?  Or can it be made simpler?
>
> Use p2m_is_ram() instead of checking individual p2m ram type
> enumerations.
> Use [un]map_domain_page instead of [un]map_domain_page_global.
>
>  -- Keir
>
> > Thanks,
> > Dan
> >
> > #include <asm/p2m.h>
> > static int
> > copy_page_from_guest(struct page_info *dst_pi,
> XEN_GUEST_HANDLE(void) gpfn)
> > {
> >     int i;
> >     unsigned long dst_mfn, guest_mfn;
> >     void *dst_va, *guest_va;
> >     p2m_type_t t;
> >
> >     if (is_pv_32on64_vcpu(current))
> >         gpfn.p = (void *)((unsigned long)gpfn.p & 0xfffffUL);
> >     dst_mfn = page_to_mfn(dst_pi);
> >     guest_mfn = gfn_to_mfn(current->domain,(unsigned
> long)gpfn.p,&t);
> >     if (t != p2m_ram_rw && t != p2m_ram_ro)
> >         return(0);  /* do I need to worry about p2m_ram_logdirty? */
> >     dst_va = map_domain_page_global(dst_mfn);
> >     guest_va = map_domain_page_global(guest_mfn);
> > /*  i = __copy_from_guest(dst_va, guest_va, PAGE_SIZE); */
> >     i = __copy_from_user(dst_va, guest_va, PAGE_SIZE);
> >     unmap_domain_page_global(guest_va);
> >     unmap_domain_page_global(dst_va);
> >     return (!i);
> > }
> >
> >
> >> -----Original Message-----
> >> From:
> >> Sent: Saturday, September 27, 2008 8:38 PM
> >> To: Dan Magenheimer; Xen-Devel (E-mail)
> >> Subject: RE: [Xen-devel] guest physical to xen machine copy?
> >>
> >>
> >> You can try gfn_to_mfn...
> >>
> >> Thanks,
> >> Kevin
> >>
> >>> From: Dan Magenheimer
> >>> Sent: 2008年9月28日 5:33
> >>>
> >>> Sorry for my poor x86 memory model knowlege...
> >>>
> >>> In some code I am working on, I currently pass the
> >>> address of a guest page from a domain via a hypercall
> >>> and in Xen either copy to or from the guest page
> >>> using:
> >>>
> >>> __copy_from_guest(xen_va, guest_va, PAGE_SIZE)
> >>>
> >>> or
> >>>
> >>> __copy_to_guest(guest_va, xen_va, PAGE_SIZE)
> >>>
> >>> where guest_va is declared as a XEN_GUEST_HANDLE(void)
> >>>
> >>> Now I'd like to switch the hypercall interface so
> >>> that the domain passes a guest physical address
> >>> (or guest physical frame number) instead of a guest
> >>> virtual address.
> >>>
> >>> I see code that does get_gpfn_from_mfn() but not
> >>> the opposite.  What do I need to do to copy a
> >>> page of data from a guest pfn to a Xen mfn (or
> >>> vice versa)?  And is a guest physical address
> >>> still referenced as a XEN_GUEST_HANDLE?
> >>>
> >>> It's probably very simple but I can't find it...
> >>>
> >>> Thanks,
> >>> Dan
> >>>
> >>> P.S. This has to work on 32- or 64-bit guests to
> >>> both 32- and 64-bit hypervisors.
> >>>
> >>> _______________________________________________
> >>> Xen-devel mailing list
> >>> Xen-devel@xxxxxxxxxxxxxxxxxxx
> >>> http://lists.xensource.com/xen-devel
> >>>
> >>
> >
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@xxxxxxxxxxxxxxxxxxx
> > http://lists.xensource.com/xen-devel
>
>
>

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