direct-io.hg

changeset 13374:328deec3febf

[XEN] Fix some e820 start-of-day issues by clipping all E820_RAM
regions to be page-sized and -aligned.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@localhost.localdomain
date Sun Jan 14 13:15:13 2007 +0000 (2007-01-14)
parents eb19c2745b80
children a6f10ffa07a0
files xen/arch/x86/setup.c
line diff
     1.1 --- a/xen/arch/x86/setup.c	Sun Jan 14 12:03:31 2007 +0000
     1.2 +++ b/xen/arch/x86/setup.c	Sun Jan 14 13:15:13 2007 +0000
     1.3 @@ -411,6 +411,23 @@ void __init __start_xen(multiboot_info_t
     1.4          printk("WARNING: Buggy e820 map detected and fixed "
     1.5                 "(truncated length fields).\n");
     1.6  
     1.7 +    /* Ensure that all E820 RAM regions are page-aligned and -sized. */
     1.8 +    for ( i = 0; i < e820_raw_nr; i++ )
     1.9 +    {
    1.10 +        uint64_t s, e;
    1.11 +        if ( e820_raw[i].type != E820_RAM )
    1.12 +            continue;
    1.13 +        s = PFN_UP(e820_raw[i].addr);
    1.14 +        e = PFN_DOWN(e820_raw[i].addr + e820_raw[i].size);
    1.15 +        e820_raw[i].size = 0; /* discarded later */
    1.16 +        if ( s < e )
    1.17 +        {
    1.18 +            e820_raw[i].addr = s << PAGE_SHIFT;
    1.19 +            e820_raw[i].size = (e - s) << PAGE_SHIFT;
    1.20 +        }
    1.21 +    }
    1.22 +
    1.23 +    /* Sanitise the raw E820 map to produce a final clean version. */
    1.24      max_page = init_e820(e820_raw, &e820_raw_nr);
    1.25  
    1.26      modules_length = mod[mbi->mods_count-1].mod_end - mod[0].mod_start;
    1.27 @@ -423,7 +440,7 @@ void __init __start_xen(multiboot_info_t
    1.28              printk("Not enough memory to stash the DOM0 kernel image.\n");
    1.29              for ( ; ; ) ;
    1.30          }
    1.31 -        
    1.32 +
    1.33          if ( (e820.map[i].type == E820_RAM) &&
    1.34               (e820.map[i].size >= modules_length) &&
    1.35               ((e820.map[i].addr + e820.map[i].size) >=
    1.36 @@ -474,10 +491,10 @@ void __init __start_xen(multiboot_info_t
    1.37              start = PFN_UP(e820.map[i].addr);
    1.38              end   = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
    1.39              /* Clip the range to exclude what the bootstrapper initialised. */
    1.40 -            if ( end < init_mapped )
    1.41 -                continue;
    1.42              if ( start < init_mapped )
    1.43                  start = init_mapped;
    1.44 +            if ( end <= start )
    1.45 +                continue;
    1.46              /* Request the mapping. */
    1.47              map_pages_to_xen(
    1.48                  PAGE_OFFSET + (start << PAGE_SHIFT),