ia64/xen-unstable

changeset 19631:cafab2084410

x86: don't map more than the allocated space for frame_table

This is to avoid undue virtual address aliases in case the over-mapped
pages happen to get allocated to a domain, and then get their
cacheability attributes changed.

At the same time, use 1Gb mappings if possible and reasonable.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed May 20 15:35:32 2009 +0100 (2009-05-20)
parents 1695a86b3d7c
children b0966b6f5180
files xen/arch/x86/mm.c
line diff
     1.1 --- a/xen/arch/x86/mm.c	Wed May 20 15:30:36 2009 +0100
     1.2 +++ b/xen/arch/x86/mm.c	Wed May 20 15:35:32 2009 +0100
     1.3 @@ -154,7 +154,7 @@ static DEFINE_PER_CPU(struct percpu_mm_i
     1.4  struct domain *dom_xen, *dom_io;
     1.5  
     1.6  /* Frame table and its size in pages. */
     1.7 -struct page_info *frame_table;
     1.8 +struct page_info *__read_mostly frame_table;
     1.9  unsigned long max_page;
    1.10  unsigned long total_pages;
    1.11  
    1.12 @@ -186,11 +186,18 @@ void __init init_frametable(void)
    1.13      frame_table = (struct page_info *)FRAMETABLE_VIRT_START;
    1.14  
    1.15      nr_pages  = PFN_UP(max_page * sizeof(*frame_table));
    1.16 -    page_step = (1 << L2_PAGETABLE_SHIFT) >> PAGE_SHIFT;
    1.17 +    page_step = 1 << (cpu_has_page1gb ? L3_PAGETABLE_SHIFT - PAGE_SHIFT
    1.18 +                                      : L2_PAGETABLE_SHIFT - PAGE_SHIFT);
    1.19  
    1.20      for ( i = 0; i < nr_pages; i += page_step )
    1.21      {
    1.22 -        mfn = alloc_boot_pages(min(nr_pages - i, page_step), page_step);
    1.23 +        /*
    1.24 +         * The hardcoded 4 below is arbitrary - just pick whatever you think
    1.25 +         * is reasonable to waste as a trade-off for using a large page.
    1.26 +         */
    1.27 +        while (nr_pages + 4 - i < page_step)
    1.28 +            page_step >>= PAGETABLE_ORDER;
    1.29 +        mfn = alloc_boot_pages(page_step, page_step);
    1.30          if ( mfn == 0 )
    1.31              panic("Not enough memory for frame table\n");
    1.32          map_pages_to_xen(