Skip to content
Tags

, ,

Machine Frame Numbers (mfns) & Physical Frame Numbers (pfns)

March 3, 2011

Normal kernel (without Xen) maps to RAM using PFN. But in Xen many virtual machines are running on hypervisor. Hence there is need of mapping pages from the kernel to hypervisor.
Mfn’s are mapped by hypervisor and hence pfns which are physical address to kernel are virtual address to xen hypervisor.
MFNs configuration can be seen in the following file :
/xen/include/asm-x86/config.h

Following are the conversions for mapping.
/* 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)
#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))

Using following method page tables are created in Xen:
void *alloc_xen_pagetable(void)

Advertisements

From → Kernel, Xen

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: