From: Tim Deegan Subject: Re: Questions for the shadow page code Date: Fri, 11 Mar 2011 09:19:11 +0000 Message-ID: <20110311091911.GB24523@whitby.uk.xensource.com> References: <53223977.4c0f.12ea2c48806.Coremail.yffbrave@163.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Return-path: Content-Disposition: inline In-Reply-To: <53223977.4c0f.12ea2c48806.Coremail.yffbrave@163.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Yao Cc: xen-devel List-Id: xen-devel@lists.xenproject.org Hi, At 02:35 +0000 on 11 Mar (1299810912), Yao wrote: > 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? 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.) > 2.What's the function of sh_linear_l2_table & the whole return > sentence? It's the same situation in the shadow_get_and_cr eate_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. > 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. -- Tim Deegan Principal Software Engineer, Xen Platform Team Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)