Hi, I looked at the function xc_translate_foreign_address(), and see that it walks the page table of the guest VM. So at best, it should return the pfn of the guest (?) We can see taht the Later part of the function is like this: ... if (pt_levels >= 3) mfn = (pte & L0_PAGETABLE_MASK_PAE) >> PAGE_SHIFT; else mfn = (pte & L0_PAGETABLE_MASK) >> PAGE_SHIFT; .. return mfn; So perhaps I miss something, but the "mfn" here should be "pfn", so this function should return pfn, not mfn as in the comment of xenctrl.h. This makes me very confused now. Thanks, Jun _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jun Koi
2008-Dec-19 14:38 UTC
[Xen-devel] Re: xc_translate_foreign_address() returns mfn??
On Fri, Dec 19, 2008 at 7:16 PM, Jun Koi <junkoi2004@gmail.com> wrote:> Hi, > > I looked at the function xc_translate_foreign_address(), and see that > it walks the page table of the guest VM. So at best, it should return > the pfn of the guest (?) > > We can see taht the Later part of the function is like this: > ... > if (pt_levels >= 3) > mfn = (pte & L0_PAGETABLE_MASK_PAE) >> PAGE_SHIFT; > else > mfn = (pte & L0_PAGETABLE_MASK) >> PAGE_SHIFT; > .. > return mfn; > > So perhaps I miss something, but the "mfn" here should be "pfn", so > this function should return pfn, not mfn as in the comment of > xenctrl.h. > > This makes me very confused now.So everything indicates that xc_translate_foreign_address() actually returns gfn, not mfn like in its comment. Could anybody confirms that the function works well on both PV and HVM? And I think xc_map_foreign_range() actually works with gfn, not mfn. Does it work with both PV and HVM, too? Thanks, Jun _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Tim Deegan
2008-Dec-19 17:13 UTC
Re: [Xen-devel] Re: xc_translate_foreign_address() returns mfn??
Hi, At 23:38 +0900 on 19 Dec (1229729882), Jun Koi wrote:> So everything indicates that xc_translate_foreign_address() actually > returns gfn, not mfn like in its comment. Could anybody confirms that > the function works well on both PV and HVM?To the best of my knowledge that function does not work at all for HVM (at least, I know it is broken when using 32-bit tools and 64-bit xen). I have a half-done patchset that cleans it up considerably, fixing HVM and compat issues, which I''ll probably post at the end of the month. In any case, you are right: these functions (like _almost_ every other interface dealing with guest memory) deals in what in the shadow code are called GFNs. That is, untranslated GPFNs for HVM guests, and MFNs for PV. The use of "mfn" in the source code is probably an indicator that this code pre-dates HVM guest support.> And I think xc_map_foreign_range() actually works with gfn, not mfn. > Does it work with both PV and HVM, too?Yes indeed! Lots of other things rely on it (qemu-dm, save/restore, etc). Cheers, Tim. -- Tim Deegan <Tim.Deegan@citrix.com> Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.] _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jun Koi
2008-Dec-19 23:40 UTC
Re: [Xen-devel] Re: xc_translate_foreign_address() returns mfn??
On Sat, Dec 20, 2008 at 2:13 AM, Tim Deegan <Tim.Deegan@citrix.com> wrote:> Hi, > > At 23:38 +0900 on 19 Dec (1229729882), Jun Koi wrote: >> So everything indicates that xc_translate_foreign_address() actually >> returns gfn, not mfn like in its comment. Could anybody confirms that >> the function works well on both PV and HVM? > > To the best of my knowledge that function does not work at all for HVM > (at least, I know it is broken when using 32-bit tools and 64-bit xen). > I have a half-done patchset that cleans it up considerably, fixing HVM > and compat issues, which I''ll probably post at the end of the month. > > In any case, you are right: these functions (like _almost_ every other > interface dealing with guest memory) deals in what in the shadow code are > called GFNs. That is, untranslated GPFNs for HVM guests, and MFNs for PV. > > The use of "mfn" in the source code is probably an indicator that this > code pre-dates HVM guest support.That is a smart guess, I think :-) And please fix the comment to reflect this in your new code. Many thanks, J _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Possibly Parallel Threads
- Bug with xc_translate_foreign_address?
- xenpaing: one way to avoid paging out the page, when the corresponding mfn is in use.
- [PATCH 0 of 4 RFC] Populate-on-demand: Check pages being returned by the balloon driver
- Some problems about xenpaging
- question about mapping memory from Dom0 to domU