[Lguest] [patch 31/43] lguest: Boot with virtual == physical to get closer to native Linux.

Rusty Russell rusty at rustcorp.com.au
Sat Sep 29 23:02:38 EST 2007


On Wed, 2007-09-26 at 17:12 -0700, Jeremy Fitzhardinge wrote:
> rusty at 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?

Hi Jeremy,

	It's probably overkill, but it has the advantage of being
straightforward and futureproof.

Cheers,
Rusty.





More information about the Lguest mailing list