debuggers.hg

changeset 21281:3ce824963dc4

Support Linux's advanced crashkernel= syntax

Quoting the original Linux patch's description:

"This patch adds a extended crashkernel syntax that makes the value of
reserved system RAM dependent on the system RAM itself:

crashkernel=3D<range1>:<size1>[,<range2>:<size2>,...][@offset]
range=3Dstart-[end]

For example:

crashkernel=3D512M-2G:64M,2G-:128M

The motivation comes from distributors that configure their
crashkernel command line automatically with some configuration tool
(YaST, you know ;)). Of course that tool knows the value of System
RAM, but if the user removes RAM, then the system becomes unbootable
or at least unusable and error handling is very difficult."

For x86, other than Linux we pass the actual amount of RAM rather than
the highest page's address (to cope with sparse physical address
maps).

This still needs to be hooked up for ia64.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Apr 26 12:12:12 2010 +0100 (2010-04-26)
parents d01ea51fc929
children 9a1d7caa2024
files xen/arch/x86/setup.c xen/common/kexec.c xen/include/xen/kexec.h
line diff
     1.1 --- a/xen/arch/x86/setup.c	Mon Apr 26 12:11:30 2010 +0100
     1.2 +++ b/xen/arch/x86/setup.c	Mon Apr 26 12:12:12 2010 +0100
     1.3 @@ -643,6 +643,11 @@ void __init __start_xen(unsigned long mb
     1.4      memcpy(&boot_e820, &e820, sizeof(e820));
     1.5  
     1.6      /* Early kexec reservation (explicit static start address). */
     1.7 +    nr_pages = 0;
     1.8 +    for ( i = 0; i < e820.nr_map; i++ )
     1.9 +        if ( e820.map[i].type == E820_RAM )
    1.10 +            nr_pages += e820.map[i].size >> PAGE_SHIFT;
    1.11 +    set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT);
    1.12      kexec_reserve_area(&boot_e820);
    1.13  
    1.14      /*
     2.1 --- a/xen/common/kexec.c	Mon Apr 26 12:11:30 2010 +0100
     2.2 +++ b/xen/common/kexec.c	Mon Apr 26 12:12:12 2010 +0100
     2.3 @@ -47,15 +47,109 @@ static unsigned char vmcoreinfo_data[VMC
     2.4  static size_t vmcoreinfo_size = 0;
     2.5  
     2.6  xen_kexec_reserve_t kexec_crash_area;
     2.7 +static struct {
     2.8 +    u64 start, end;
     2.9 +    unsigned long size;
    2.10 +} ranges[16] __initdata;
    2.11  
    2.12 +/*
    2.13 + * Parse command lines in the format
    2.14 + *
    2.15 + *   crashkernel=<ramsize-range>:<size>[,...][@<offset>]
    2.16 + *
    2.17 + * with <ramsize-range> being of form
    2.18 + *
    2.19 + *   <start>-[<end>]
    2.20 + *
    2.21 + * as well as the legacy ones in the format
    2.22 + *
    2.23 + *   crashkernel=<size>[@<offset>]
    2.24 + */
    2.25  static void __init parse_crashkernel(const char *str)
    2.26  {
    2.27 -    kexec_crash_area.size = parse_size_and_unit(str, &str);
    2.28 -    if ( *str == '@' )
    2.29 -        kexec_crash_area.start = parse_size_and_unit(str+1, NULL);
    2.30 +    const char *cur;
    2.31 +
    2.32 +    if ( strchr(str, ':' ) )
    2.33 +    {
    2.34 +        unsigned int idx = 0;
    2.35 +
    2.36 +        do {
    2.37 +            if ( idx >= ARRAY_SIZE(ranges) )
    2.38 +            {
    2.39 +                printk(XENLOG_WARNING "crashkernel: too many ranges\n");
    2.40 +                cur = NULL;
    2.41 +                str = strchr(str, '@');
    2.42 +                break;
    2.43 +            }
    2.44 +
    2.45 +            ranges[idx].start = parse_size_and_unit(cur = str + !!idx, &str);
    2.46 +            if ( cur == str )
    2.47 +                break;
    2.48 +
    2.49 +            if ( *str != '-' )
    2.50 +            {
    2.51 +                printk(XENLOG_WARNING "crashkernel: '-' expected\n");
    2.52 +                break;
    2.53 +            }
    2.54 +
    2.55 +            if ( *++str != ':' )
    2.56 +            {
    2.57 +                ranges[idx].end = parse_size_and_unit(cur = str, &str);
    2.58 +                if ( cur == str )
    2.59 +                    break;
    2.60 +                if ( ranges[idx].end <= ranges[idx].start )
    2.61 +                {
    2.62 +                    printk(XENLOG_WARNING "crashkernel: end <= start\n");
    2.63 +                    break;
    2.64 +                }
    2.65 +            }
    2.66 +            else
    2.67 +                ranges[idx].end = -1;
    2.68 +
    2.69 +            if ( *str != ':' )
    2.70 +            {
    2.71 +                printk(XENLOG_WARNING "crashkernel: ':' expected\n");
    2.72 +                break;
    2.73 +            }
    2.74 +
    2.75 +            ranges[idx].size = parse_size_and_unit(cur = str + 1, &str);
    2.76 +            if ( cur == str )
    2.77 +                break;
    2.78 +
    2.79 +            ++idx;
    2.80 +        } while ( *str == ',' );
    2.81 +        if ( idx < ARRAY_SIZE(ranges) )
    2.82 +            ranges[idx].size = 0;
    2.83 +    }
    2.84 +    else
    2.85 +        kexec_crash_area.size = parse_size_and_unit(cur = str, &str);
    2.86 +    if ( cur != str && *str == '@' )
    2.87 +        kexec_crash_area.start = parse_size_and_unit(cur = str + 1, &str);
    2.88 +    if ( cur == str )
    2.89 +        printk(XENLOG_WARNING "crashkernel: memory value expected\n");
    2.90  }
    2.91  custom_param("crashkernel", parse_crashkernel);
    2.92  
    2.93 +void __init set_kexec_crash_area_size(u64 system_ram)
    2.94 +{
    2.95 +    unsigned int idx;
    2.96 +
    2.97 +    for ( idx = 0; idx < ARRAY_SIZE(ranges) && !kexec_crash_area.size; ++idx )
    2.98 +    {
    2.99 +        if ( !ranges[idx].size )
   2.100 +            break;
   2.101 +
   2.102 +        if ( ranges[idx].size >= system_ram )
   2.103 +        {
   2.104 +            printk(XENLOG_WARNING "crashkernel: invalid size\n");
   2.105 +            continue;
   2.106 +        }
   2.107 +
   2.108 +        if ( ranges[idx].start <= system_ram && ranges[idx].end > system_ram )
   2.109 +            kexec_crash_area.size = ranges[idx].size;
   2.110 +    }
   2.111 +}
   2.112 +
   2.113  static void one_cpu_only(void)
   2.114  {
   2.115      /* Only allow the first cpu to continue - force other cpus to spin */
     3.1 --- a/xen/include/xen/kexec.h	Mon Apr 26 12:11:30 2010 +0100
     3.2 +++ b/xen/include/xen/kexec.h	Mon Apr 26 12:12:12 2010 +0100
     3.3 @@ -12,6 +12,8 @@ typedef struct xen_kexec_reserve {
     3.4  
     3.5  extern xen_kexec_reserve_t kexec_crash_area;
     3.6  
     3.7 +void set_kexec_crash_area_size(u64 system_ram);
     3.8 +
     3.9  /* We have space for 4 images to support atomic update
    3.10   * of images. This is important for CRASH images since
    3.11   * a panic can happen at any time...