Kai Luo
2013-Jun-02 06:19 UTC
Questions about the mapping from gpfn to mfn when live migration
Hi everyone: I am reading code of live migration process of hvm domain now.My question is that I can''t find the transformation position that transform hvm domain‘s gpfn to mfn.That is,the method ,in file xc_linux_osdep.c, linux_privcmd_map_foreign_bulk( xc_interface *xch, xc_osdep_handle h, uint32_t dom, int prot, const xen_pfn_t *arr, int *err, unsigned int num) ,the list of xen_pfn_t contains the list of guest''s mfns(gpfns in xen),for para-virtualization guests they are thransformed by the pfn_to_mfn() before assignment(in xc_domain_save()),for hvm guests however,I can not find a similar conversion process,they are directly conveyed to the dom''s kernel directly without any transformation.So I continued to follow the process,finding the following key functions: privcmd_ioctl (struct file *file, unsigned int cmd, unsigned long data) ->privcmd_ioctl_mmap_batch(udata, 2) ->-> traverse_pages(mmapcmd.num, sizeof(struct privcmd_mmap_entry), &pagelist, mmap_mfn_range, &state); Still no clue for the thransformation process,could you give any sugguestions? My second question is that is it possible that I give a list of hvm''s mfns(not gpfns) and then get the contents held in memory in dom0?Does xen have any function of this kind? Thank you all! Jone _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Andrew Cooper
2013-Jun-03 09:49 UTC
Re: Questions about the mapping from gpfn to mfn when live migration
On 02/06/13 07:19, Kai Luo wrote:> Hi everyone: > I am reading code of live migration process of hvm domain now.My > question is that I can''t find the transformation position that > transform hvm domain‘s gpfn to mfn.That is,the method ,in file > xc_linux_osdep.c,linux_privcmd_map_foreign_bulk(xc_interface *xch, > xc_osdep_handle h,uint32_t dom, int prot,const xen_pfn_t *arr, int > *err, unsigned int num),the list of xen_pfn_t contains the list of > guest''s mfns(gpfns in xen),for para-virtualization guests they are > thransformed by the pfn_to_mfn() before assignment(in > xc_domain_save()),for hvm guests however,I can not find a similar > conversion process,they are directly conveyed to the dom''s kernel > directly without any transformation.So I continued to follow the > process,finding the following key functions: > privcmd_ioctl(struct file *file,unsigned int cmd, unsigned long data) > ->privcmd_ioctl_mmap_batch(udata, 2) > ->-> traverse_pages(mmapcmd.num, sizeof(struct > privcmd_mmap_entry),&pagelist,mmap_mfn_range, &state); > Still no clue for the thransformation process,could you give any > sugguestions? > My second question is that is it possible that I give a list of > hvm''s mfns(not gpfns) and then get the contents held in memory in > dom0?Does xen have any function of this kind? > Thank you all! > JoneXen does the transformation. All mapping functions take "Guest physical addresses", i.e. the values a guest puts in their pagetables. For PV guests, this is MFNs but for HVM guests, only Xen can read the EPT/NPT pagetables to transform guest physical into host physical. I am not aware of any supported interface which would allow dom0 to map raw mfns, nor should there be. What is the problem you are trying to solve by doing this? ~Andrew --------------090208080201020906010700 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 8bit <html> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> </head> <body text="#000000" bgcolor="#FFFFFF"> <div class="moz-cite-prefix">On 02/06/13 07:19, Kai Luo wrote:<br> </div> <blockquote cite="mid:1315453738.1404628.1370153965900.JavaMail.root@vmware.com" type="cite"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"> <div>Hi everyone:</div> <div> I am reading code of live migration process of hvm domain now.My question is that I can''t find the transformation position that transform hvm domain‘s gpfn to mfn.That is,the method ,in file xc_linux_osdep.c,<span style="color: rgb(255, 0, 0);" data-mce-style="color: #ff0000;">linux_privcmd_map_foreign_bulk(<span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">xc_interface *xch, xc_osdep_handle h,</span><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">uint32_t dom, int prot,</span></span><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"><span style="color: rgb(255, 0, 0);">const xen_pfn_t *arr, int *err, unsigned int num)</span>,the list of xen_pfn_t contains the list of guest''s mfns(gpfns in xen),for para-virtualization guests they are thransformed by the pfn_to_mfn() before assignment(in xc_domain_save()),for hvm guests however,I can not find a similar conversion process,they are directly conveyed to the dom''s kernel directly without any transformation.So I continued to follow the process,finding the following key functions:</span></div> <div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"> <span style="color: rgb(255, 0, 0);" data-mce-style="color: #ff0000;"> <span style="color: rgb(0, 0, 0);" data-mce-style="color: #000000;">privcmd_ioctl</span></span>(struct file *file,</span><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">unsigned int cmd, unsigned long data) </span></span></span></div> <div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"> ->privcmd_ioctl_mmap_batch(udata, 2)</span></span></span></div> <div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"> ->-> </span></span></span><span style="font-size: 12pt;"> traverse_pages(mmapcmd.num, sizeof(struct privcmd_mmap_entry),</span><span style="font-size: 12pt;">&pagelist,</span><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"></span></span><span style="font-size: 12pt;">mmap_mfn_range, &state);</span></div> <div><span style="font-size: 12pt;"> Still no clue for the thransformation process,could you give any sugguestions?</span></div> <div><span style="font-size: 12pt;"> My second question is that is it possible that I give a list of hvm''s mfns(not gpfns) and then get the contents held in memory in dom0?Does xen have any function of this kind?</span></div> <div><span style="font-size: 12pt;">Thank you all!</span></div> <div><span style="font-size: 12pt;">Jone </span></div> </div> </blockquote> <br> Xen does the transformation.<br> <br> All mapping functions take "Guest physical addresses", i.e. the values a guest puts in their pagetables. For PV guests, this is MFNs but for HVM guests, only Xen can read the EPT/NPT pagetables to transform guest physical into host physical.<br> <br> I am not aware of any supported interface which would allow dom0 to map raw mfns, nor should there be. What is the problem you are trying to solve by doing this?<br> <br> ~Andrew<br> </body> </html> --------------090208080201020906010700-- --===============4264751063150668275=Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============4264751063150668275==--