ia64/xen-unstable

changeset 6106:a64ac7fafbf0

PAE page directories must be below 4GB. Based on a patch
from Gerd Knorr.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Aug 11 10:34:32 2005 +0000 (2005-08-11)
parents d95ea17567c6
children 0761551e993a
files linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c xen/arch/x86/domain_build.c xen/arch/x86/mm.c xen/include/asm-x86/page.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c	Thu Aug 11 08:59:47 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c	Thu Aug 11 10:34:32 2005 +0000
     1.3 @@ -25,6 +25,7 @@
     1.4  #include <asm/mmu_context.h>
     1.5  
     1.6  #include <asm-xen/foreign_page.h>
     1.7 +#include <asm-xen/hypervisor.h>
     1.8  
     1.9  void show_mem(void)
    1.10  {
    1.11 @@ -274,6 +275,11 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
    1.12  {
    1.13  	unsigned long flags;
    1.14  
    1.15 +#ifdef CONFIG_X86_PAE
    1.16 +	/* this gives us a page below 4GB */
    1.17 +	xen_contig_memory((unsigned long)pgd, 0);
    1.18 +#endif
    1.19 +
    1.20  	if (!HAVE_SHARED_KERNEL_PMD)
    1.21  		spin_lock_irqsave(&pgd_lock, flags);
    1.22  
     2.1 --- a/xen/arch/x86/domain_build.c	Thu Aug 11 08:59:47 2005 +0000
     2.2 +++ b/xen/arch/x86/domain_build.c	Thu Aug 11 10:34:32 2005 +0000
     2.3 @@ -74,7 +74,7 @@ int construct_dom0(struct domain *d,
     2.4                     unsigned long _initrd_start, unsigned long initrd_len,
     2.5                     char *cmdline)
     2.6  {
     2.7 -    int i, rc, dom0_pae, xen_pae;
     2.8 +    int i, rc, dom0_pae, xen_pae, order;
     2.9      unsigned long pfn, mfn;
    2.10      unsigned long nr_pages;
    2.11      unsigned long nr_pt_pages;
    2.12 @@ -143,10 +143,6 @@ int construct_dom0(struct domain *d,
    2.13          nr_pages = avail_domheap_pages() +
    2.14              ((initrd_len + PAGE_SIZE - 1) >> PAGE_SHIFT) +
    2.15              ((image_len  + PAGE_SIZE - 1) >> PAGE_SHIFT);
    2.16 -    if ( (page = alloc_largest(d, nr_pages)) == NULL )
    2.17 -        panic("Not enough RAM for DOM0 reservation.\n");
    2.18 -    alloc_spfn = page_to_pfn(page);
    2.19 -    alloc_epfn = alloc_spfn + d->tot_pages;
    2.20  
    2.21      if ( (rc = parseelfimage(&dsi)) != 0 )
    2.22          return rc;
    2.23 @@ -215,8 +211,15 @@ int construct_dom0(struct domain *d,
    2.24  #endif
    2.25      }
    2.26  
    2.27 -    if ( ((v_end - dsi.v_start) >> PAGE_SHIFT) > (alloc_epfn - alloc_spfn) )
    2.28 -        panic("Insufficient contiguous RAM to build kernel image.\n");
    2.29 +    order = get_order(v_end - dsi.v_start);
    2.30 +    if ( (1UL << order) > nr_pages )
    2.31 +        panic("Domain 0 allocation is too small for kernel image.\n");
    2.32 +
    2.33 +    /* Allocate from DMA pool: PAE L3 table must be below 4GB boundary. */
    2.34 +    if ( (page = alloc_domheap_pages(d, order, ALLOC_DOM_DMA)) == NULL )
    2.35 +        panic("Not enough RAM for domain 0 allocation.\n");
    2.36 +    alloc_spfn = page_to_pfn(page);
    2.37 +    alloc_epfn = alloc_spfn + d->tot_pages;
    2.38  
    2.39      printk("PHYSICAL MEMORY ARRANGEMENT:\n"
    2.40             " Dom0 alloc.:   %"PRIphysaddr"->%"PRIphysaddr,
     3.1 --- a/xen/arch/x86/mm.c	Thu Aug 11 08:59:47 2005 +0000
     3.2 +++ b/xen/arch/x86/mm.c	Thu Aug 11 10:34:32 2005 +0000
     3.3 @@ -856,6 +856,14 @@ static int alloc_l3_table(struct pfn_inf
     3.4  
     3.5      ASSERT(!shadow_mode_refcounts(d));
     3.6  
     3.7 +#ifdef CONFIG_X86_PAE
     3.8 +    if ( pfn >= 0x100000 )
     3.9 +    {
    3.10 +        MEM_LOG("PAE pgd must be below 4GB (0x%lx >= 0x100000)", pfn);
    3.11 +        return 0;
    3.12 +    }
    3.13 +#endif
    3.14 +
    3.15      pl3e = map_domain_page(pfn);
    3.16      for ( i = 0; i < L3_PAGETABLE_ENTRIES; i++ )
    3.17      {
     4.1 --- a/xen/include/asm-x86/page.h	Thu Aug 11 08:59:47 2005 +0000
     4.2 +++ b/xen/include/asm-x86/page.h	Thu Aug 11 10:34:32 2005 +0000
     4.3 @@ -283,13 +283,9 @@ extern void paging_init(void);
     4.4  static __inline__ int get_order(unsigned long size)
     4.5  {
     4.6      int order;
     4.7 -    
     4.8 -    size = (size-1) >> (PAGE_SHIFT-1);
     4.9 -    order = -1;
    4.10 -    do {
    4.11 +    size = (size-1) >> PAGE_SHIFT;
    4.12 +    for ( order = 0; size; order++ )
    4.13          size >>= 1;
    4.14 -        order++;
    4.15 -    } while (size);
    4.16      return order;
    4.17  }
    4.18