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

Jeremy Fitzhardinge jeremy at goop.org
Thu Sep 27 10:12:42 EST 2007


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?

    J



More information about the Lguest mailing list