direct-io.hg

changeset 15521:1f348e70a5af

Re-factor e820 truncation code and reintroduce clipping for 32-on-64
guests (to 166GB).
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Jul 10 11:10:38 2007 +0100 (2007-07-10)
parents 73290f6fe70a
children 3de536b5e5fe
files xen/arch/x86/e820.c
line diff
     1.1 --- a/xen/arch/x86/e820.c	Tue Jul 10 10:22:41 2007 +0100
     1.2 +++ b/xen/arch/x86/e820.c	Tue Jul 10 11:10:38 2007 +0100
     1.3 @@ -310,23 +310,22 @@ static unsigned long __init find_max_pfn
     1.4      return max_pfn;
     1.5  }
     1.6  
     1.7 -#ifdef __i386__
     1.8 -static void __init clip_4gb(void)
     1.9 +static void __init clip_to_limit(uint64_t limit, char *warnmsg)
    1.10  {
    1.11 -    unsigned long long limit = (1ULL << 30) * MACHPHYS_MBYTES;
    1.12      int i;
    1.13 +    char _warnmsg[160];
    1.14  
    1.15 -    /* 32-bit systems restricted to a 4GB physical memory map,
    1.16 -     * with PAE to 16 GB (with current memory layout) */
    1.17      for ( i = 0; i < e820.nr_map; i++ )
    1.18      {
    1.19          if ( (e820.map[i].addr + e820.map[i].size) <= limit )
    1.20              continue;
    1.21 -        printk("WARNING: Only the first %d GB of the physical memory map "
    1.22 -               "can be accessed\n"
    1.23 -               "         by Xen in 32-bit mode. "
    1.24 -               "Truncating the memory map...\n",
    1.25 -	       MACHPHYS_MBYTES);
    1.26 +        if ( warnmsg )
    1.27 +        {
    1.28 +            snprintf(_warnmsg, sizeof(_warnmsg), warnmsg, (int)(limit>>30));
    1.29 +            printk("WARNING: %s\n", _warnmsg);
    1.30 +        }
    1.31 +        printk("Truncating memory map to %lukB\n",
    1.32 +               (unsigned long)(limit >> 10));
    1.33          if ( e820.map[i].addr >= limit )
    1.34          {
    1.35              e820.nr_map = i;
    1.36 @@ -338,34 +337,6 @@ static void __init clip_4gb(void)
    1.37          }            
    1.38      }
    1.39  }
    1.40 -#else
    1.41 -#define clip_4gb() ((void)0)
    1.42 -#endif
    1.43 -
    1.44 -static void __init clip_mem(void)
    1.45 -{
    1.46 -    int i;
    1.47 -
    1.48 -    if ( !opt_mem )
    1.49 -        return;
    1.50 -
    1.51 -    for ( i = 0; i < e820.nr_map; i++ )
    1.52 -    {
    1.53 -        if ( (e820.map[i].addr + e820.map[i].size) <= opt_mem )
    1.54 -            continue;
    1.55 -        printk("Truncating memory map to %lukB\n",
    1.56 -               (unsigned long)(opt_mem >> 10));
    1.57 -        if ( e820.map[i].addr >= opt_mem )
    1.58 -        {
    1.59 -            e820.nr_map = i;
    1.60 -        }
    1.61 -        else
    1.62 -        {
    1.63 -            e820.map[i].size = opt_mem - e820.map[i].addr;
    1.64 -            e820.nr_map = i + 1;          
    1.65 -        }
    1.66 -    }
    1.67 -}
    1.68  
    1.69  static void __init machine_specific_memory_setup(
    1.70      struct e820entry *raw, int *raw_nr)
    1.71 @@ -374,8 +345,22 @@ static void __init machine_specific_memo
    1.72      sanitize_e820_map(raw, &nr);
    1.73      *raw_nr = nr;
    1.74      (void)copy_e820_map(raw, nr);
    1.75 -    clip_4gb();
    1.76 -    clip_mem();
    1.77 +
    1.78 +    if ( opt_mem )
    1.79 +        clip_to_limit(opt_mem, NULL);
    1.80 +
    1.81 +#ifdef __i386__
    1.82 +    clip_to_limit((1ULL << 30) * MACHPHYS_MBYTES,
    1.83 +                  "Only the first %u GB of the physical memory map "
    1.84 +                  "can be accessed by Xen in 32-bit mode.");
    1.85 +#endif
    1.86 +
    1.87 +#ifdef __x86_64__
    1.88 +    clip_to_limit((uint64_t)(MACH2PHYS_COMPAT_VIRT_END -
    1.89 +                             __HYPERVISOR_COMPAT_VIRT_START) << 10,
    1.90 +                  "Only the first %u GB of the physical memory map "
    1.91 +                  "can be accessed by 32-on-64 guests.");
    1.92 +#endif
    1.93  }
    1.94  
    1.95  unsigned long __init init_e820(