Xen Memory Management

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);    

xen_memory_translation

Pinning pages

Sharing pages with other domains

 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值