Questions for the shadow page code
Hi, guys
Lately I've been researching the implementation of the shadow page and I didn't really understand the mechanism. For instance, the function shadow_get_and_create_l*e in x86/mm/shadow/multi.c If the GuestOS is 32-bit, then shadow_get_and_create_l1e should execute
{
*sl2mfn = pagetable_get_mfn(v->arch.shadow_table[0]);
(void) shadow_l2_index(sl2mfn, guest_l2_table_offset(gw->va));
return sh_linear_l2_table(v) + shadow_l2_linear_offset(gw->va);
}1.How does the Xen organize the spt? it looks like xen used 36-bit pae for spt, but how does it correspond to the guest 2 level page table?
2.What's the function of sh_linear_l2_table & the whole return sentence? It's the same situation in the shadow_get_and_create_l2e. There are some assemble code and it screw me up :( 3.Are there any docs to help me to figure it out?
Regards,
Yao
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Hi,
Quoted 10 lines · Yao
If the GuestOS is 32-bit, then
shadow_get_and_create_l1eshould execute{ *sl2mfn = pagetable_get_mfn(v->arch.shadow_table[0]); (void) shadow_l2_index(sl2mfn, guest_l2_table_offset(gw->va)); return sh_linear_l2_table(v) + shadow_l2_linear_offset(gw->va); }1.How does the Xen organize the spt? it looks like xen used 36-bit pae for spt, but how does it correspond to the guest 2 level page table?
Yes. The shadow page tables _must_ be PAE or 64-bit in order to be able to use machine memory >4GiB for VMs. From the comments in shadow/common.c:
* A 32-bit guest l1 table covers 4MB
* of virtual address space, and needs to be shadowed by two PAE/64-bit
* l1 tables (covering 2MB of virtual address space each). Similarly, a
* 32-bit guest l2 table (4GB va) needs to be shadowed by four
* PAE/64-bit l2 tables (1GB va each). These multi-page shadows are
* not contiguous in memory; functions for handling offsets into them are
* defined in shadow/multi.c (shadow_l1_index() etc.)
Quoted 2 lines
2.What's the function of
sh_linear_l2_table& the whole return sentence? It's the same situation in theshadow_get_and_create_l2e.
sh_linear_l2_table is a linear mapping of the _shadow_ pagetables. Xen's pagetables have two linear mappings in them - one of the pagetables you're running on (__linear_l1_table &c in page.h) and one of the current VCPU's shadow pagetables (__sh_linear_l1_table &c in types.h). sh_linear_l*_table is a macro that mixes those appropriately to generate the address where a shadow PTE will be visible.
Quoted 3 lines
There are some assemble code and it screw me up :(
3.Are there any docs to help me to figure it out?
Sorry, there's only the code and the mailing list archives.
Cheers,
Tim.
Signature · 3 lines
Tim Deegan <[email protected]> Principal Software Engineer, Xen Platform Team Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)