From: Tim Deegan Subject: Re: [RFC] New shadow paging code Date: Mon, 17 Jul 2006 16:30:26 +0100 Message-ID: <20060717153026.GA5498@york.uk.xensource.com> References: <20060714153907.GJ3328@york.uk.xensource.com> <44BB9F68.8070803@us.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Return-path: Content-Disposition: inline In-Reply-To: <44BB9F68.8070803@us.ibm.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: "Mike D. Day" Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org At 10:32 -0400 on 17 Jul (1153132328), Mike D. Day wrote: > Can you explain how this works? It is not obvious to me from the patch. > In shadow2.c there is in fact a whole string of #ifs. What mechanism > causes the file to be multiply compiled? Or do I misunderstand how this > works? It's handled by the makefile runes that go into in xen/arch/x86/Makefile. For each type of host, a number of shadow2_gX_on_sY.o files are required, and the rule for shadow2_%.o compiles shadow2.c with the appropriate definitions for GUEST_PAGING_LEVELS and SHADOW_PAGING_LEVELS. > Also, can you comment on the differences and similarities with the > shadow code contributed by Ben Thomas? There are some similarities: for example both patches allocate a pool of shadow memory for each domain, rather than allocating from domheap on the fly. Also, we're currently working on incorporating the idea of storing guest present/writable bits in the shadow pte for fast-path of "genuine" faults. The major difference in structure is that the XI patch keeps the "out-of-sync" algorithm of the old shadow code, letting guests write to their pagetables and re-syncing the shadow on a fault. This works well for linux's fork()/exit() behaviour, but for Windows, which mostly does demand paging, it makes the cycle of fault-install-retry rather expensive. Instead, the shadow2 patch emulates all writes to pagetables, without ever letting the guest write to a shadowed page directly. XI also has a reverse-mapping mechanism for recording where all the pagetable entries are that reference each page; this doubles the memory cost of shadow mode, and adds some book-keeping, but avoids having to search through all the shadows when revoking write access to a guest page. We believe it's possible to use heuristics to speed up the remove-all-writable-mappings process, without the memory overhead. For example, just looking in the kernel's linear map works in 99.8% of cases for Windows 2003 Server. As for features, XI supports only HVM guests on 64-bit Xen; shadow2 supports 32-bit and PAE Xen as well, and PV guests. As I understand it, there is no plan to make XI support any other modes. XI supports shadowing superpages directly with superpages, which shadow2 does not (yet). Cheers, Tim.