From: "Jan Beulich" Subject: [PATCH] support Linux' advanced crashkernel= syntax (v2) Date: Mon, 26 Apr 2010 09:00:10 +0100 Message-ID: <4BD5642A020000780003C16B@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartA48E371A.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: xen-ia64-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartA48E371A.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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:[,:,...][@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 --- 2010-04-22.orig/xen/arch/x86/setup.c 2010-04-23 00:00:00.0000000= 00 +0200 +++ 2010-04-22/xen/arch/x86/setup.c 2010-04-26 08:52:06.000000000 = +0200 @@ -643,6 +643,11 @@ void __init __start_xen(unsigned long mb memcpy(&boot_e820, &e820, sizeof(e820)); =20 /* Early kexec reservation (explicit static start address). */ + nr_pages =3D 0; + for ( i =3D 0; i < e820.nr_map; i++ ) + if ( e820.map[i].type =3D=3D E820_RAM ) + nr_pages +=3D e820.map[i].size >> PAGE_SHIFT; + set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT); kexec_reserve_area(&boot_e820); =20 /* --- 2010-04-22.orig/xen/common/kexec.c 2010-01-13 18:58:11.000000000 = +0100 +++ 2010-04-22/xen/common/kexec.c 2010-04-26 09:52:29.000000000 = +0200 @@ -47,15 +47,109 @@ static unsigned char vmcoreinfo_data[VMC static size_t vmcoreinfo_size =3D 0; =20 xen_kexec_reserve_t kexec_crash_area; +static struct { + u64 start, end; + unsigned long size; +} ranges[16] __initdata; =20 +/* + * Parse command lines in the format + * + * crashkernel=3D:[,...][@] + * + * with being of form + * + * -[] + * + * as well as the legacy ones in the format + * + * crashkernel=3D[@] + */ static void __init parse_crashkernel(const char *str) { - kexec_crash_area.size =3D parse_size_and_unit(str, &str); - if ( *str =3D=3D '@' ) - kexec_crash_area.start =3D parse_size_and_unit(str+1, NULL); + const char *cur; + + if ( strchr(str, ':' ) ) + { + unsigned int idx =3D 0; + + do { + if ( idx >=3D ARRAY_SIZE(ranges) ) + { + printk(XENLOG_WARNING "crashkernel: too many ranges\n"); + cur =3D NULL; + str =3D strchr(str, '@'); + break; + } + + ranges[idx].start =3D parse_size_and_unit(cur =3D str + = !!idx, &str); + if ( cur =3D=3D str ) + break; + + if ( *str !=3D '-' ) + { + printk(XENLOG_WARNING "crashkernel: '-' expected\n"); + break; + } + + if ( *++str !=3D ':' ) + { + ranges[idx].end =3D parse_size_and_unit(cur =3D str, = &str); + if ( cur =3D=3D str ) + break; + if ( ranges[idx].end <=3D ranges[idx].start ) + { + printk(XENLOG_WARNING "crashkernel: end <=3D = start\n"); + break; + } + } + else + ranges[idx].end =3D -1; + + if ( *str !=3D ':' ) + { + printk(XENLOG_WARNING "crashkernel: ':' expected\n"); + break; + } + + ranges[idx].size =3D parse_size_and_unit(cur =3D str + 1, = &str); + if ( cur =3D=3D str ) + break; + + ++idx; + } while ( *str =3D=3D ',' ); + if ( idx < ARRAY_SIZE(ranges) ) + ranges[idx].size =3D 0; + } + else + kexec_crash_area.size =3D parse_size_and_unit(cur =3D str, &str); + if ( cur !=3D str && *str =3D=3D '@' ) + kexec_crash_area.start =3D parse_size_and_unit(cur =3D str + 1, = &str); + if ( cur =3D=3D str ) + printk(XENLOG_WARNING "crashkernel: memory value expected\n"); } custom_param("crashkernel", parse_crashkernel); =20 +void __init set_kexec_crash_area_size(u64 system_ram) +{ + unsigned int idx; + + for ( idx =3D 0; idx < ARRAY_SIZE(ranges) && !kexec_crash_area.size; = ++idx ) + { + if ( !ranges[idx].size ) + break; + + if ( ranges[idx].size >=3D system_ram ) + { + printk(XENLOG_WARNING "crashkernel: invalid size\n"); + continue; + } + + if ( ranges[idx].start <=3D system_ram && ranges[idx].end > = system_ram ) + kexec_crash_area.size =3D ranges[idx].size; + } +} + static void one_cpu_only(void) { /* Only allow the first cpu to continue - force other cpus to spin */ --- 2010-04-22.orig/xen/include/xen/kexec.h 2010-01-13 18:58:11.0000000= 00 +0100 +++ 2010-04-22/xen/include/xen/kexec.h 2010-04-26 08:43:26.000000000 = +0200 @@ -12,6 +12,8 @@ typedef struct xen_kexec_reserve { =20 extern xen_kexec_reserve_t kexec_crash_area; =20 +void set_kexec_crash_area_size(u64 system_ram); + /* We have space for 4 images to support atomic update * of images. This is important for CRASH images since * a panic can happen at any time... --=__PartA48E371A.0__= Content-Type: text/plain; name="crashkernel-advanced.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="crashkernel-advanced.patch" Quoting the original Linux patch's description:=0A=0A"This patch adds a = extended crashkernel syntax that makes the value of=0A reserved system RAM = dependent on the system RAM itself:=0A=0A crashkernel=3D:= [,:,...][@offset]=0A range=3Dstart-[end]=0A=0A For = example:=0A=0A crashkernel=3D512M-2G:64M,2G-:128M=0A=0A The motivation = comes from distributors that configure their=0A crashkernel command line = automatically with some configuration tool=0A (YaST, you know ;)). Of = course that tool knows the value of System=0A RAM, but if the user removes = RAM, then the system becomes unbootable=0A or at least unusable and error = handling is very difficult."=0A=0AFor x86, other than Linux we pass the = actual amount of RAM rather than=0Athe highest page's address (to cope = with sparse physical address maps).=0A=0AThis still needs to be hooked up = for ia64.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = 2010-04-22.orig/xen/arch/x86/setup.c 2010-04-23 00:00:00.000000000 = +0200=0A+++ 2010-04-22/xen/arch/x86/setup.c 2010-04-26 08:52:06.0000000= 00 +0200=0A@@ -643,6 +643,11 @@ void __init __start_xen(unsigned long = mb=0A memcpy(&boot_e820, &e820, sizeof(e820));=0A =0A /* Early = kexec reservation (explicit static start address). */=0A+ nr_pages =3D = 0;=0A+ for ( i =3D 0; i < e820.nr_map; i++ )=0A+ if ( e820.map[i]= .type =3D=3D E820_RAM )=0A+ nr_pages +=3D e820.map[i].size >> = PAGE_SHIFT;=0A+ set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT);= =0A kexec_reserve_area(&boot_e820);=0A =0A /*=0A--- 2010-04-22.orig= /xen/common/kexec.c 2010-01-13 18:58:11.000000000 +0100=0A+++ = 2010-04-22/xen/common/kexec.c 2010-04-26 09:52:29.000000000 +0200=0A@@ = -47,15 +47,109 @@ static unsigned char vmcoreinfo_data[VMC=0A static = size_t vmcoreinfo_size =3D 0;=0A =0A xen_kexec_reserve_t kexec_crash_area;= =0A+static struct {=0A+ u64 start, end;=0A+ unsigned long size;=0A+} = ranges[16] __initdata;=0A =0A+/*=0A+ * Parse command lines in the = format=0A+ *=0A+ * crashkernel=3D:[,...][@]= =0A+ *=0A+ * with being of form=0A+ *=0A+ * -[]=0A+ *=0A+ * as well as the legacy ones in the format=0A+ *=0A+ * = crashkernel=3D[@]=0A+ */=0A static void __init parse_crashker= nel(const char *str)=0A {=0A- kexec_crash_area.size =3D parse_size_and_u= nit(str, &str);=0A- if ( *str =3D=3D '@' )=0A- kexec_crash_area.s= tart =3D parse_size_and_unit(str+1, NULL);=0A+ const char *cur;=0A+=0A+ = if ( strchr(str, ':' ) )=0A+ {=0A+ unsigned int idx =3D = 0;=0A+=0A+ do {=0A+ if ( idx >=3D ARRAY_SIZE(ranges) = )=0A+ {=0A+ printk(XENLOG_WARNING "crashkernel: = too many ranges\n");=0A+ cur =3D NULL;=0A+ = str =3D strchr(str, '@');=0A+ break;=0A+ = }=0A+=0A+ ranges[idx].start =3D parse_size_and_unit(cur =3D str = + !!idx, &str);=0A+ if ( cur =3D=3D str )=0A+ = break;=0A+=0A+ if ( *str !=3D '-' )=0A+ {=0A+ = printk(XENLOG_WARNING "crashkernel: '-' expected\n");=0A+ = break;=0A+ }=0A+=0A+ if ( *++str !=3D ':' = )=0A+ {=0A+ ranges[idx].end =3D parse_size_and_un= it(cur =3D str, &str);=0A+ if ( cur =3D=3D str )=0A+ = break;=0A+ if ( ranges[idx].end <=3D ranges[idx]= .start )=0A+ {=0A+ printk(XENLOG_WARNING = "crashkernel: end <=3D start\n");=0A+ break;=0A+ = }=0A+ }=0A+ else=0A+ = ranges[idx].end =3D -1;=0A+=0A+ if ( *str !=3D ':' )=0A+ = {=0A+ printk(XENLOG_WARNING "crashkernel: ':' expected\n= ");=0A+ break;=0A+ }=0A+=0A+ = ranges[idx].size =3D parse_size_and_unit(cur =3D str + 1, &str);=0A+ = if ( cur =3D=3D str )=0A+ break;=0A+=0A+ = ++idx;=0A+ } while ( *str =3D=3D ',' );=0A+ if ( idx < = ARRAY_SIZE(ranges) )=0A+ ranges[idx].size =3D 0;=0A+ }=0A+ = else=0A+ kexec_crash_area.size =3D parse_size_and_unit(cur =3D = str, &str);=0A+ if ( cur !=3D str && *str =3D=3D '@' )=0A+ = kexec_crash_area.start =3D parse_size_and_unit(cur =3D str + 1, &str);=0A+ = if ( cur =3D=3D str )=0A+ printk(XENLOG_WARNING "crashkernel: = memory value expected\n");=0A }=0A custom_param("crashkernel", parse_crashk= ernel);=0A =0A+void __init set_kexec_crash_area_size(u64 system_ram)=0A+{= =0A+ unsigned int idx;=0A+=0A+ for ( idx =3D 0; idx < ARRAY_SIZE(rang= es) && !kexec_crash_area.size; ++idx )=0A+ {=0A+ if ( !ranges[idx= ].size )=0A+ break;=0A+=0A+ if ( ranges[idx].size >=3D = system_ram )=0A+ {=0A+ printk(XENLOG_WARNING "crashkernel= : invalid size\n");=0A+ continue;=0A+ }=0A+=0A+ = if ( ranges[idx].start <=3D system_ram && ranges[idx].end > system_ram = )=0A+ kexec_crash_area.size =3D ranges[idx].size;=0A+ = }=0A+}=0A+=0A static void one_cpu_only(void)=0A {=0A /* Only allow the = first cpu to continue - force other cpus to spin */=0A--- 2010-04-22.orig/x= en/include/xen/kexec.h 2010-01-13 18:58:11.000000000 +0100=0A+++ = 2010-04-22/xen/include/xen/kexec.h 2010-04-26 08:43:26.000000000 = +0200=0A@@ -12,6 +12,8 @@ typedef struct xen_kexec_reserve {=0A =0A extern = xen_kexec_reserve_t kexec_crash_area;=0A =0A+void set_kexec_crash_area_size= (u64 system_ram);=0A+=0A /* We have space for 4 images to support atomic = update=0A * of images. This is important for CRASH images since=0A * a = panic can happen at any time...=0A --=__PartA48E371A.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__PartA48E371A.0__=--