direct-io.hg

changeset 4254:ed581e07c97f

bitkeeper revision 1.1236.1.107 (423fe7a68FOsyuQeKM4k2_0KKlkoEg)

Calling alloc_boot_pages() after end_boot_allocator() can result in
double allocation of the same page.
Signed-off-by: Chengyuan Li <chengyuan.li@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Mar 22 09:38:46 2005 +0000 (2005-03-22)
parents db5cb5193ffc
children 5f91e746684c
files xen/arch/x86/x86_64/mm.c
line diff
     1.1 --- a/xen/arch/x86/x86_64/mm.c	Tue Mar 22 09:03:36 2005 +0000
     1.2 +++ b/xen/arch/x86/x86_64/mm.c	Tue Mar 22 09:38:46 2005 +0000
     1.3 @@ -28,12 +28,26 @@
     1.4  #include <asm/fixmap.h>
     1.5  #include <asm/msr.h>
     1.6  
     1.7 -void *safe_page_alloc(void)
     1.8 +static void *safe_page_alloc(void)
     1.9  {
    1.10      extern int early_boot;
    1.11      if ( early_boot )
    1.12 -        return __va(alloc_boot_pages(PAGE_SIZE, PAGE_SIZE));
    1.13 -    return (void *)alloc_xenheap_page();
    1.14 +    {
    1.15 +        unsigned long p = alloc_boot_pages(PAGE_SIZE, PAGE_SIZE);
    1.16 +        if ( p == 0 )
    1.17 +            goto oom;
    1.18 +        return phys_to_virt(p);
    1.19 +    }
    1.20 +    else
    1.21 +    {
    1.22 +        struct pfn_info *pg = alloc_domheap_page(NULL);
    1.23 +        if ( pg == NULL )
    1.24 +            goto oom;
    1.25 +        return page_to_virt(pg);
    1.26 +    }
    1.27 + oom:
    1.28 +    panic("Out of memory");
    1.29 +    return NULL;
    1.30  }
    1.31  
    1.32  /* Map physical byte range (@p, @p+@s) at virt address @v in pagetable @pt. */
    1.33 @@ -118,6 +132,7 @@ void __init paging_init(void)
    1.34  {
    1.35      unsigned long i, p, max;
    1.36      l3_pgentry_t *l3rw, *l3ro;
    1.37 +    struct pfn_info *pg;
    1.38  
    1.39      /* Map all of physical memory. */
    1.40      max = ((max_page + L1_PAGETABLE_ENTRIES - 1) & 
    1.41 @@ -130,10 +145,11 @@ void __init paging_init(void)
    1.42       */
    1.43      for ( i = 0; i < max_page; i += ((1UL << L2_PAGETABLE_SHIFT) / 8) )
    1.44      {
    1.45 -        p = alloc_boot_pages(1UL << L2_PAGETABLE_SHIFT,
    1.46 -                             1UL << L2_PAGETABLE_SHIFT);
    1.47 -        if ( p == 0 )
    1.48 +        pg = alloc_domheap_pages(
    1.49 +            NULL, L2_PAGETABLE_SHIFT - L1_PAGETABLE_SHIFT);
    1.50 +        if ( pg == NULL )
    1.51              panic("Not enough memory for m2p table\n");
    1.52 +        p = page_to_phys(pg);
    1.53          map_pages(idle_pg_table, RDWR_MPT_VIRT_START + i*8, p, 
    1.54                    1UL << L2_PAGETABLE_SHIFT, PAGE_HYPERVISOR | _PAGE_USER);
    1.55          memset((void *)(RDWR_MPT_VIRT_START + i*8), 0x55,