hi,all I recently encoutered a piece of code in the following , + //grab a page we''ll share with the guest + comm->shared_page_ptr = alloc_xenheap_page(); + comm->shared_page_mfn = virt_to_mfn(comm->shared_page_ptr); + + page = mfn_to_page(comm->shared_page_mfn); + share_xen_page_with_privileged_guests(page, XENSHARE_writable); I cannot figure out the theory or principle of it, can anyone explain to me? please file : xen/include/asm-x86/page.h /* Convert between Xen-heap virtual addresses and machine addresses. */ #define __pa(x) (virt_to_maddr(x)) #define __va(x) (maddr_to_virt(x)) /* Convert between Xen-heap virtual addresses and machine frame numbers. */ #define __virt_to_mfn(va) (virt_to_maddr(va) >> PAGE_SHIFT) #define __mfn_to_virt(mfn) (maddr_to_virt((paddr_t)(mfn) << PAGE_SHIFT)) /* Convert between machine frame numbers and page-info structures. */ #define __mfn_to_page(mfn) (frame_table + pfn_to_pdx(mfn)) #define __page_to_mfn(pg) pdx_to_pfn((unsigned long)((pg) - frame_table)) /* Convert between machine addresses and page-info structures. */ #define __maddr_to_page(ma) __mfn_to_page((ma) >> PAGE_SHIFT) #define __page_to_maddr(pg) ((paddr_t)__page_to_mfn(pg) << PAGE_SHIFT) /* Convert between frame number and address formats. */ #define __pfn_to_paddr(pfn) ((paddr_t)(pfn) << PAGE_SHIFT) #define __paddr_to_pfn(pa) ((unsigned long)((pa) >> PAGE_SHIFT)) /* Convert between machine frame numbers and spage-info structures. */ #define __mfn_to_spage(mfn) (spage_table + pfn_to_sdx(mfn)) #define __spage_to_mfn(pg) sdx_to_pfn((unsigned long)((pg) - spage_table)) /* Convert between page-info structures and spage-info structures. */ #define page_to_spage(page) (spage_table+(((page)-frame_table)>>(SUPERPAGE_SHIFT-PAGE_SHIFT))) #define spage_to_page(spage) (frame_table+(((spage)-spage_table)<<(SUPERPAGE_SHIFT-PAGE_SHIFT))) /* * We define non-underscored wrappers for above conversion functions. These are * overridden in various source files while underscored versions remain intact. */ #define mfn_valid(mfn) __mfn_valid(mfn) #define virt_to_mfn(va) __virt_to_mfn(va) #define mfn_to_virt(mfn) __mfn_to_virt(mfn) #define virt_to_maddr(va) __virt_to_maddr((unsigned long)(va)) #define maddr_to_virt(ma) __maddr_to_virt((unsigned long)(ma)) #define mfn_to_page(mfn) __mfn_to_page(mfn) #define page_to_mfn(pg) __page_to_mfn(pg) #define mfn_to_spage(mfn) __mfn_to_spage(mfn) #define spage_to_mfn(pg) __spage_to_mfn(pg) #define maddr_to_page(ma) __maddr_to_page(ma) #define page_to_maddr(pg) __page_to_maddr(pg) #define virt_to_page(va) __virt_to_page(va) #define page_to_virt(pg) __page_to_virt(pg) #define pfn_to_paddr(pfn) __pfn_to_paddr(pfn) #define paddr_to_pfn(pa) __paddr_to_pfn(pa) #define paddr_to_pdx(pa) pfn_to_pdx(paddr_to_pfn(pa)) -- ---------------------------------------------------------- regards, yandong _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
On Thu, Jun 13, 2013 at 02:21:57PM +0800, yandong han wrote:> hi,all > > I recently encoutered a piece of code in the following , > > + //grab a page we''ll share with the guest > + comm->shared_page_ptr = alloc_xenheap_page(); > + comm->shared_page_mfn = virt_to_mfn(comm->shared_page_ptr); > + > + page = mfn_to_page(comm->shared_page_mfn); > + share_xen_page_with_privileged_guests(page, XENSHARE_writable); > > I cannot figure out the theory or principle of it, can anyone explain to > me? please > >You will know it better if you understand the concepts of Xen terminologies. http://wiki.xen.org/wiki/XenTerminology Wei.