From: Mark Williamson Subject: Re: Setting up page directories and tables Date: Tue, 1 May 2007 17:27:14 +0100 Message-ID: <200705011727.15732.mark.williamson@cl.cam.ac.uk> References: <2d88d46a0704271311m4f41aa6bna46cc903bb619f32@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <2d88d46a0704271311m4f41aa6bna46cc903bb619f32@mail.gmail.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Joel Weinberger , Dave Pacheco , Keir Fraser List-Id: xen-devel@lists.xenproject.org > This OS is designed for 32-bit x86 (no PAE), so I intend to use a two-level > paging system. Each process has a page directory - one page with entries > which point to page tables, whose entries describe actual pages. As far as > I can tell, this is what's done in the Mini-OS source, with page > directories referred to as L1 page tables, and what I'm calling page tables > referred to as L2 page tables. I think you've got this backwards: in Xen code, L1 page tables are the leaf nodes, L2 are their parents, L3 are their parents, etc etc. Cheers, Mark > So when creating a process, I do the following: > allocate a page P for the process's page directory > fill P with zeros > update the existing page table mapping for P (previously set up by what > is essentially the build_pagetable() code from Mini-OS) to give it L1_PROT > & ~_PAGE_RW > (using HYPERVISOR_mmu_update(...)) > pin the page (using HYPERVISOR_mmuext_op({MMUEXT_PIN_L1_TABLE, > ...}...)) > > All of these steps succeed (the hypercall returns 0, and the argument > indicating how many updates succeeded is 1 in both cases). But later, when > switching into the context of this process, I try to update the user base > pointer with > > HYPERVISOR_mmuext_op({MMUEXT_NEW_USER_BASEPTR, mfn of P}...). > > This call fails (returns -1, and indicates that 0 operations succeeded). > Why might that be? As I've established, the page is zero'd out (so it's not > invalid), and it seems to be mapped properly (not writable, pinned L1 page > table). So why would this operation fail? > > Thanks in advance, > Dave Pacheco -- Dave: Just a question. What use is a unicyle with no seat? And no pedals! Mark: To answer a question with a question: What use is a skateboard? Dave: Skateboards have wheels. Mark: My wheel has a wheel!