您的位置:首页 > 其它

Xen Memory Management

2007-05-22 21:28 393 查看

Introduction

Unless otherwise noted, the information here refers to Xen/unstable for x86.

Guest interface to Xen memory management

Start of day

At the StartOfDay (when a guest domain has just started), the Xen hypervisor passes a pointer to a start_info_t structure. This contains an initial page directory address (pt_base) and an address to the PhysicalAddress to MachineAddress translation (mfn_list).

Physical memory handed to the domain

Updating the page tables

Can someone review this part and fix misunderstandings and errors? // SimonKagstrom
We assume that an application causes a page fault on e.g., code in a shared library, i.e. code that is in physical memory but not mapped to the application. We'll assume that the page directory exists, but does not have a page table or a page mapped for the faulting virtual address. The following will then happen (the steps are outlined in the figure below):
1. Xen receives the page fault and delivers it to the guest through the trap table (installed by HYPERVISOR_set_trap_table()). The guest will thereafter lookup a physical page to map into the application.

page_fault_handler(virt_addr) {
...
pgdir_entry = virt_to_pgdir(virt_addr);
pgtab_entry = virt_to_pgtab(virt_addr);
phys_page = virt_to_phys(virt_addr);
...


2. The guest looks up the page directory and finds that there exists no mapping (to a page table) for that address.
3. To get a new page table page, the guest will

Get a new page (get_page()) for the page table

Translate the pseudo-physical address of the page to a machine address through the machine->physical translation table, e.g.,

pgtab = get_page();
pgtab_mach_addr = machine_to_physical(pgtab);


4. The guest inserts the machine address of the page table page into the page directory through HYPERVISOR_MMU_update(), i.e., something like (simplified syntax)

HYPERVISOR_mmu_update(pgdir_entry | MMU_NORMAL_PT_UPDATE, pgtab_mach_addr | PGTAB_PROTECTION, ...);


(the page table page is now accessible)
5. The guest must then instruct Xen to pin this page as a page table page (simplified syntax):

HYPERVISOR_mmuext_op(MMUEXT_PIN_L2_TABLE, pgtab_mach_addr, ...);


6. Finally the guest will map the physical page into the page table

phys_page_mach_addr = machine_to_physical(phys_page);




Pinning pages

Sharing pages with other domains

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: