Richard
2005-Feb-25  00:09 UTC
[Xen-devel] memory manager in Mini-os - are initial page tables still placed at the top of memory ???
Hello,
I am still working on mini-os :).
I think that the memory manager (file mm.c) for mini-os is pretty
outdated. I just want to confirm something. In the function init_mm()
in file mm.c, it is assumed that XEN places the initial page tables at
the TOP of the available memory. Mini-os uses that information to
calculate the number of free page frames available to use. Is that
still the case nowadays ?
Below is part of the function init_mm() and the comments inside init_mm()
========================================================================  
unsigned long *pgd = (unsigned long *)start_info.pt_base;
    /* set up minimal memory infos */
    start_pfn = PFN_UP(to_phys(&_end));
    max_pfn = start_info.nr_pages;
    printk("  start_pfn:    %lx\n", start_pfn);
    printk("  max_pfn:      %lx\n", max_pfn);
    /*
     * we know where free tables start (start_pfn) and how many we 
     * have (max_pfn). 
     * 
     * Currently the hypervisor stores page tables it providesin the
     * high region of the this memory range.
     * 
     * next we work out how far down this goes (max_free_pfn)
     * 
     * XXX this assumes the hypervisor provided page tables to be in
     * the upper region of our initial memory. I don''t know if this 
     * is always true.
     */
    max_free_pfn = PFN_DOWN(to_phys(pgd));
    {
        unsigned long *pgd = (unsigned long *)start_info.pt_base;
        unsigned long  pte;
        int i;
        printk("  pgd(pa(pgd)): %lx(%lx)", (u_long)pgd, to_phys(pgd));
        for ( i = 0; i < (HYPERVISOR_VIRT_START>>22); i++ )
        {
            unsigned long pgde = *pgd++;
            if ( !(pgde & 1) ) continue;
            pte = machine_to_phys(pgde & PAGE_MASK);
            printk("  PT(%x): %lx(%lx)", i, (u_long)to_virt(pte),
pte);
            if (PFN_DOWN(pte) <= max_free_pfn) 
                max_free_pfn = PFN_DOWN(pte);
        }
    }
    max_free_pfn--;
    printk("  max_free_pfn: %lx\n", max_free_pfn);
========================================================================
Thanks
Richard
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xen-devel