From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeremy Fitzhardinge Subject: Re: [patch 31/43] lguest: Boot with virtual == physical to get closer to native Linux. Date: Wed, 26 Sep 2007 17:12:42 -0700 Message-ID: <46FAF57A.5020105@goop.org> References: <20070926063618.956228976@rustcorp.com.au> <20070926063650.704084137@rustcorp.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20070926063650.704084137@rustcorp.com.au> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: rusty@rustcorp.com.au Cc: lguest@ozlabs.org, virtualization@lists.linux-foundation.org List-Id: virtualization@lists.linuxfoundation.org rusty@rustcorp.com.au wrote: > +/* We walk down the guest page tables to get a guest-physical address */ > +unsigned long guest_pa(struct lguest *lg, unsigned long vaddr) > +{ > + pgd_t gpgd; > + pte_t gpte; > + > + /* First step: get the top-level Guest page table entry. */ > + gpgd = __pgd(lgread_u32(lg, gpgd_addr(lg, vaddr))); > + /* Toplevel not present? We can't map it in. */ > + if (!(pgd_flags(gpgd) & _PAGE_PRESENT)) > + kill_guest(lg, "Bad address %#lx", vaddr); > + > + gpte = __pte(lgread_u32(lg, gpte_addr(lg, gpgd, vaddr))); > + if (!(pte_flags(gpte) & _PAGE_PRESENT)) > + kill_guest(lg, "Bad address %#lx", vaddr); > + > + return pte_pfn(gpte) * PAGE_SIZE | (vaddr & ~PAGE_MASK); > +} That's nice and general, but is it necessary? Is this just to handle the two cases of booting with P=V, then switching to the normal kernel offset? J