direct-io.hg

changeset 15457:08bcc54aee8e

x86: Improve e820 scanning for all I/O regions.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Jul 03 12:02:31 2007 +0100 (2007-07-03)
parents eb2b7ce05f97
children 8adfd96f62ae
files xen/arch/x86/mm.c
line diff
     1.1 --- a/xen/arch/x86/mm.c	Tue Jul 03 11:47:08 2007 +0100
     1.2 +++ b/xen/arch/x86/mm.c	Tue Jul 03 12:02:31 2007 +0100
     1.3 @@ -211,23 +211,37 @@ void __init arch_init_memory(void)
     1.4          share_xen_page_with_guest(mfn_to_page(i), dom_io, XENSHARE_writable);
     1.5   
     1.6      /* Any areas not specified as RAM by the e820 map are considered I/O. */
     1.7 -    for ( i = 0, pfn = 0; i < e820.nr_map; i++ )
     1.8 +    pfn = i = 0;
     1.9 +    while ( pfn < max_page )
    1.10      {
    1.11 -        if ( e820.map[i].type != E820_RAM )
    1.12 -            continue;
    1.13 -        /* Every page from cursor to start of next RAM region is I/O. */
    1.14 -        rstart_pfn = PFN_UP(e820.map[i].addr);
    1.15 -        rend_pfn   = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
    1.16 +        while ( (i < e820.nr_map) && (e820.map[i].type != E820_RAM) )
    1.17 +            i++;
    1.18 +
    1.19 +        if ( i == e820.nr_map )
    1.20 +        {
    1.21 +            /* No more RAM regions: mark as I/O right to end of memory map. */
    1.22 +            rstart_pfn = rend_pfn = max_page;
    1.23 +        }
    1.24 +        else
    1.25 +        {
    1.26 +            /* Mark as I/O just up as far as next RAM region. */
    1.27 +            rstart_pfn = min_t(unsigned long, max_page,
    1.28 +                               PFN_UP(e820.map[i].addr));
    1.29 +            rend_pfn   = max_t(unsigned long, rstart_pfn,
    1.30 +                               PFN_DOWN(e820.map[i].addr + e820.map[i].size));
    1.31 +        }
    1.32 +
    1.33 +        /* Mark as I/O up to next RAM region. */
    1.34          for ( ; pfn < rstart_pfn; pfn++ )
    1.35          {
    1.36              BUG_ON(!mfn_valid(pfn));
    1.37              share_xen_page_with_guest(
    1.38                  mfn_to_page(pfn), dom_io, XENSHARE_writable);
    1.39          }
    1.40 +
    1.41          /* Skip the RAM region. */
    1.42          pfn = rend_pfn;
    1.43      }
    1.44 -    BUG_ON(pfn != max_page);
    1.45  
    1.46      subarch_init_memory();
    1.47  }