From: Dan Magenheimer Subject: RE: guest physical to xen machine copy? Date: Sun, 28 Sep 2008 13:19:00 -0700 (PDT) Message-ID: <7799e899-8873-4aa2-bf98-0e5eacb19f21@default> References: Mime-Version: 1.0 Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "Xen-Devel (E-mail)" , "Tian, Kevin" List-Id: xen-devel@lists.xenproject.org > 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? Thanks, Dan #include 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 =3D (void *)((unsigned long)gpfn.p & 0xfffffUL); dst_mfn =3D page_to_mfn(dst_pi); guest_mfn =3D gfn_to_mfn(current->domain,(unsigned long)gpfn.p,&t); if (t !=3D p2m_ram_rw && t !=3D p2m_ram_ro) return(0); /* do I need to worry about p2m_ram_logdirty? */ dst_va =3D map_domain_page_global(dst_mfn); guest_va =3D map_domain_page_global(guest_mfn); /* i =3D __copy_from_guest(dst_va, guest_va, PAGE_SIZE); */ i =3D __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=C4=EA9=D4=C228=C8=D5 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@lists.xensource.com > >http://lists.xensource.com/xen-devel > > >