Re: [Fastboot] [PATCH] Add support for longer kernel command lines (i586, x86_64, IA64)

2007-03-06 Thread Bernhard Walle
Hello,

* Vivek Goyal [EMAIL PROTECTED] [2007-03-06 05:15]:
 On Tue, Mar 06, 2007 at 09:42:04AM +0530, Vivek Goyal wrote:
  On Mon, Mar 05, 2007 at 11:34:33PM +0100, Bernhard Walle wrote:
   This patch increases the kernel command line size for x86_64 and i386
   to 2048 characters. This is necessary because with kernel 2.6.21
   and newer, the kernel command line size has increased and kexec needs
   lot of command line space, so this solves some command line overflow
   problems.
   
   To be able to warn users running older kernels that the command line
   is too long (and don't wait that the kernel truncates it), the
   patch tries to get the kernel command line length from the kernel
   image that is loaded if possible by checking the length of the
   static array that holds the kernel command line when booting.
  
  It does not work for compressed images (bzImage). So kexing older bzImages
  will never give you a warning message.
  
  Secondly, I think creating dependencies on kernel symbols is bad. Tomorrow
  if kernel code changes, we are broken. The problem crash faces so often.
  So we should create a well defined interface which can remain constant 
  even if kernel code changes.
  
  I personally think either there should be a way to specify command line
  length supported in the image format (bzImage) or we should export it to 
  user space, lets say through /proc/ interface. 
  
  Specifying max cmdline lenght in bzImage header helps because any bootloader
  then take a clue and warn user about excessive command line length.
  
  Otherwise we can export something like /proc/max_cmdline_len on the lines
  of /proc/cmdline.
 
 Thinking more about it. I think exporting it through /proc/ will work better.
 Extending bzImage format will help only bzImage but problem for ELF vmlniux
 will still persist, until we decide to append an ELF note to vmlinux.

A /proc interface is a bit useless IMO. It tells you about the command
line size of the running kernel, but not about the command line size
of the kernel you try to load.

My patch about changing the header in x86_64/i386 was not applied
(http://marc.theaimsgroup.com/?l=linux-kernelm=117138549731788w=2)
although I got positive repsonse from the maintanier (H. Peter Anvin),
but he was travelling at that time ...

I'm also not very lucky about the solution to get the size from the
ELF symbol table. Maybe a ELF not plus getting the bzImage header
applied would be the best compromise. Or do we really want to trust
that the kernel that runs has the same command line size as the kernel
that is kexec'd to?



Regards,
Bernhard
-- 
SUSE LINUX Products GmbH  Tel. +49 (911) 74053-0
Maxfeldstr. 5 GF: Markus Rex
90409 Nürnberg, Germany   HRB 16746 (AG Nürnberg)
OpenPGP DDAF6454: F61F 34CC 09CA FB82 C9F6  BA4B 8865 3696 DDAF 6454


pgp2Fgd1i4ldM.pgp
Description: PGP signature
___
fastboot mailing list
fastboot@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/fastboot


Re: [Fastboot] [PATCH] Add support for longer kernel command lines (i586, x86_64, IA64)

2007-03-06 Thread Vivek Goyal
On Tue, Mar 06, 2007 at 10:24:56AM +0100, Bernhard Walle wrote:
 Hello,
 
 * Vivek Goyal [EMAIL PROTECTED] [2007-03-06 05:15]:
  On Tue, Mar 06, 2007 at 09:42:04AM +0530, Vivek Goyal wrote:
   On Mon, Mar 05, 2007 at 11:34:33PM +0100, Bernhard Walle wrote:
This patch increases the kernel command line size for x86_64 and i386
to 2048 characters. This is necessary because with kernel 2.6.21
and newer, the kernel command line size has increased and kexec needs
lot of command line space, so this solves some command line overflow
problems.

To be able to warn users running older kernels that the command line
is too long (and don't wait that the kernel truncates it), the
patch tries to get the kernel command line length from the kernel
image that is loaded if possible by checking the length of the
static array that holds the kernel command line when booting.
   
   It does not work for compressed images (bzImage). So kexing older bzImages
   will never give you a warning message.
   
   Secondly, I think creating dependencies on kernel symbols is bad. Tomorrow
   if kernel code changes, we are broken. The problem crash faces so often.
   So we should create a well defined interface which can remain constant 
   even if kernel code changes.
   
   I personally think either there should be a way to specify command line
   length supported in the image format (bzImage) or we should export it to 
   user space, lets say through /proc/ interface. 
   
   Specifying max cmdline lenght in bzImage header helps because any 
   bootloader
   then take a clue and warn user about excessive command line length.
   
   Otherwise we can export something like /proc/max_cmdline_len on the lines
   of /proc/cmdline.
  
  Thinking more about it. I think exporting it through /proc/ will work 
  better.
  Extending bzImage format will help only bzImage but problem for ELF vmlniux
  will still persist, until we decide to append an ELF note to vmlinux.
 
 A /proc interface is a bit useless IMO. It tells you about the command
 line size of the running kernel, but not about the command line size
 of the kernel you try to load.
 

Oh.. You are right. Somehow it slipped out of my mind that kernel being
kexec'd might not have any relevance to the running kernel.

 My patch about changing the header in x86_64/i386 was not applied
 (http://marc.theaimsgroup.com/?l=linux-kernelm=117138549731788w=2)
 although I got positive repsonse from the maintanier (H. Peter Anvin),
 but he was travelling at that time ...
 

I think above patch then makes sense. How about posting it again and
try to get it in. May be this time Peter will like it. To me it makes
sense. Kernel image should let the bootloader know regarding what 
cmdline size does it support.

 I'm also not very lucky about the solution to get the size from the
 ELF symbol table. Maybe a ELF not plus getting the bzImage header
 applied would be the best compromise. Or do we really want to trust
 that the kernel that runs has the same command line size as the kernel
 that is kexec'd to?

We can't assume that running kernel and kernel being kexec'd to are same.
How about adding an PT_NOTE ELF note to vmlinux image exporting what's the
size of supported command line? This probably will meet some resistance but
its worth giving it a try. I consider this to be a better option then trying
to parse the symbol table and run into maintenace issues later.

Thanks
Vivek
___
fastboot mailing list
fastboot@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/fastboot


Re: [Fastboot] [PATCH] Add support for longer kernel command lines(i586, x86_64, IA64)

2007-03-06 Thread Yu, Luming
Just wondering why no IA64 code in the patch, but mentioned it in the subject.

Thanks
Luming 

-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of Bernhard Walle
Sent: 2007年3月6日 6:35
To: [EMAIL PROTECTED]
Subject: [Fastboot] [PATCH] Add support for longer kernel 
command lines(i586, x86_64, IA64)

This patch increases the kernel command line size for x86_64 and i386
to 2048 characters. This is necessary because with kernel 2.6.21
and newer, the kernel command line size has increased and kexec needs
lot of command line space, so this solves some command line overflow
problems.

To be able to warn users running older kernels that the command line
is too long (and don't wait that the kernel truncates it), the
patch tries to get the kernel command line length from the kernel
image that is loaded if possible by checking the length of the
static array that holds the kernel command line when booting.

If this is not possible or the command line is not in the range
[256; 2048], the default value is used (2048).

The patch is against kexec-tools-testing from Simon Horman.

Signed-off-by: Bernhard Walle [EMAIL PROTECTED]

---
 include/x86/x86-linux.h  |8 ++-
 kexec/arch/i386/crashdump-x86.c  |   36 
---
 kexec/arch/i386/crashdump-x86.h  |5 
 kexec/arch/i386/kexec-bzImage.c  |8 +++
 kexec/arch/i386/kexec-elf-x86.c  |8 +++
 kexec/arch/i386/x86-linux-setup.c|6 +++--
 kexec/arch/x86_64/crashdump-x86_64.c |   35 
+++---
 kexec/arch/x86_64/crashdump-x86_64.h |3 ++
 kexec/arch/x86_64/kexec-elf-x86_64.c |   11 ++
 9 files changed, 95 insertions(+), 25 deletions(-)

Index: kexec-tools-snap/include/x86/x86-linux.h
===
--- kexec-tools-snap.orig/include/x86/x86-linux.h
+++ kexec-tools-snap/include/x86/x86-linux.h
@@ -148,14 +148,12 @@ struct x86_linux_param_header {
 #endif
   struct e820entry e820_map[E820MAX]; /* 0x2d0 */
   /* 0x550 */
-#define COMMAND_LINE_SIZE 256
+#define COMMAND_LINE_SIZE 2048
 };
 
 struct x86_linux_faked_param_header {
-  struct x86_linux_param_header hdr;  /* 0x00 */
-  uint8_t reserved16[688];/* 0x550 */
-  uint8_t command_line[COMMAND_LINE_SIZE]; /* 0x800 */
-  uint8_t reserved17[1792];   /* 0x900 - 0x1000 */
+  struct x86_linux_param_header hdr;
+  uint8_t command_line[COMMAND_LINE_SIZE];
 };
 
 struct x86_linux_header {
Index: kexec-tools-snap/kexec/arch/i386/crashdump-x86.c
===
--- kexec-tools-snap.orig/kexec/arch/i386/crashdump-x86.c
+++ kexec-tools-snap/kexec/arch/i386/crashdump-x86.c
@@ -46,6 +46,36 @@ static struct memory_range crash_memory_
 /* Memory region reserved for storing panic kernel and other data. */
 static struct memory_range crash_reserved_mem;
 
+/* real length of the command line from the kernel image, 
needed because
+ * command line size on x86-64 was increased recently in -mm tree */
+int real_command_line_size = COMMAND_LINE_SIZE;
+
+
+/* Tries to read the kernel command line size from the symbol table
+ * of the ELF kernel binary. */
+void set_command_line_size(struct mem_ehdr *ehdr)
+{
+  int ret;
+  struct mem_sym mem_sym;
+
+  /*  2.6.20-rc6-mm */
+  ret = elf_rel_find_symbol(ehdr, saved_command_line, mem_sym);
+  if (ret != 0) {
+  /* older kernel */
+  ret = elf_rel_find_symbol(ehdr, 
boot_command_line, mem_sym);
+  if (ret != 0) {
+  return;
+  }
+  }
+
+  /* current -mm kernel */
+  if (mem_sym.st_size = 256  mem_sym.st_size  
COMMAND_LINE_SIZE) {
+  real_command_line_size = mem_sym.st_size;
+  return;
+  }
+}
+
+
 /* Reads the appropriate file and retrieves the SYSTEM RAM 
regions for whom to
  * create Elf headers. Keeping it separate from get_memory_ranges() as
  * requirements are different in the case of normal kexec and 
crashdumps.
@@ -363,7 +393,7 @@ static int cmdline_add_memmap(char *cmdl
   strcpy(str_mmap,  memmap=exactmap);
   len = strlen(str_mmap);
   cmdlen = strlen(cmdline) + len;
-  if (cmdlen  (COMMAND_LINE_SIZE - 1))
+  if (cmdlen  (real_command_line_size - 1))
   die(Command line overflow\n);
   strcat(cmdline, str_mmap);
 
@@ -388,7 +418,7 @@ static int cmdline_add_memmap(char *cmdl
   strcat (str_mmap, K);
   len = strlen(str_mmap);
   cmdlen = strlen(cmdline) + len;
-  if (cmdlen  (COMMAND_LINE_SIZE - 1))
+  if (cmdlen  (real_command_line_size - 1))
   die(Command line overflow\n);
   strcat(cmdline, str_mmap);
   }
@@ -418,7 +448,7 @@ static int cmdline_add_elfcorehdr(char

Re: [Fastboot] [PATCH] Add support for longer kernel command lines(i586, x86_64, IA64)

2007-03-06 Thread Bernhard Walle
Hello,

* Yu, Luming [EMAIL PROTECTED] [2007-03-06 16:18]:
 Just wondering why no IA64 code in the patch, but mentioned it in the subject.

You're right, I missed it. I'll include IA64 after I post an updated
version because of the issues Vivek explained.


Regards,
Bernhard


pgpmthfWRlj2V.pgp
Description: PGP signature
___
fastboot mailing list
fastboot@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/fastboot


[Fastboot] [PATCH] Add support for longer kernel command lines (i586, x86_64, IA64)

2007-03-05 Thread Bernhard Walle
This patch increases the kernel command line size for x86_64 and i386
to 2048 characters. This is necessary because with kernel 2.6.21
and newer, the kernel command line size has increased and kexec needs
lot of command line space, so this solves some command line overflow
problems.

To be able to warn users running older kernels that the command line
is too long (and don't wait that the kernel truncates it), the
patch tries to get the kernel command line length from the kernel
image that is loaded if possible by checking the length of the
static array that holds the kernel command line when booting.

If this is not possible or the command line is not in the range
[256; 2048], the default value is used (2048).

The patch is against kexec-tools-testing from Simon Horman.

Signed-off-by: Bernhard Walle [EMAIL PROTECTED]

---
 include/x86/x86-linux.h  |8 ++-
 kexec/arch/i386/crashdump-x86.c  |   36 ---
 kexec/arch/i386/crashdump-x86.h  |5 
 kexec/arch/i386/kexec-bzImage.c  |8 +++
 kexec/arch/i386/kexec-elf-x86.c  |8 +++
 kexec/arch/i386/x86-linux-setup.c|6 +++--
 kexec/arch/x86_64/crashdump-x86_64.c |   35 +++---
 kexec/arch/x86_64/crashdump-x86_64.h |3 ++
 kexec/arch/x86_64/kexec-elf-x86_64.c |   11 ++
 9 files changed, 95 insertions(+), 25 deletions(-)

Index: kexec-tools-snap/include/x86/x86-linux.h
===
--- kexec-tools-snap.orig/include/x86/x86-linux.h
+++ kexec-tools-snap/include/x86/x86-linux.h
@@ -148,14 +148,12 @@ struct x86_linux_param_header {
 #endif
struct e820entry e820_map[E820MAX]; /* 0x2d0 */
/* 0x550 */
-#define COMMAND_LINE_SIZE 256
+#define COMMAND_LINE_SIZE 2048
 };
 
 struct x86_linux_faked_param_header {
-   struct x86_linux_param_header hdr;  /* 0x00 */
-   uint8_t reserved16[688];/* 0x550 */
-   uint8_t command_line[COMMAND_LINE_SIZE]; /* 0x800 */
-   uint8_t reserved17[1792];   /* 0x900 - 0x1000 */
+   struct x86_linux_param_header hdr;
+   uint8_t command_line[COMMAND_LINE_SIZE];
 };
 
 struct x86_linux_header {
Index: kexec-tools-snap/kexec/arch/i386/crashdump-x86.c
===
--- kexec-tools-snap.orig/kexec/arch/i386/crashdump-x86.c
+++ kexec-tools-snap/kexec/arch/i386/crashdump-x86.c
@@ -46,6 +46,36 @@ static struct memory_range crash_memory_
 /* Memory region reserved for storing panic kernel and other data. */
 static struct memory_range crash_reserved_mem;
 
+/* real length of the command line from the kernel image, needed because
+ * command line size on x86-64 was increased recently in -mm tree */
+int real_command_line_size = COMMAND_LINE_SIZE;
+
+
+/* Tries to read the kernel command line size from the symbol table
+ * of the ELF kernel binary. */
+void set_command_line_size(struct mem_ehdr *ehdr)
+{
+   int ret;
+   struct mem_sym mem_sym;
+
+   /*  2.6.20-rc6-mm */
+   ret = elf_rel_find_symbol(ehdr, saved_command_line, mem_sym);
+   if (ret != 0) {
+   /* older kernel */
+   ret = elf_rel_find_symbol(ehdr, boot_command_line, mem_sym);
+   if (ret != 0) {
+   return;
+   }
+   }
+
+   /* current -mm kernel */
+   if (mem_sym.st_size = 256  mem_sym.st_size  COMMAND_LINE_SIZE) {
+   real_command_line_size = mem_sym.st_size;
+   return;
+   }
+}
+
+
 /* Reads the appropriate file and retrieves the SYSTEM RAM regions for whom to
  * create Elf headers. Keeping it separate from get_memory_ranges() as
  * requirements are different in the case of normal kexec and crashdumps.
@@ -363,7 +393,7 @@ static int cmdline_add_memmap(char *cmdl
strcpy(str_mmap,  memmap=exactmap);
len = strlen(str_mmap);
cmdlen = strlen(cmdline) + len;
-   if (cmdlen  (COMMAND_LINE_SIZE - 1))
+   if (cmdlen  (real_command_line_size - 1))
die(Command line overflow\n);
strcat(cmdline, str_mmap);
 
@@ -388,7 +418,7 @@ static int cmdline_add_memmap(char *cmdl
strcat (str_mmap, K);
len = strlen(str_mmap);
cmdlen = strlen(cmdline) + len;
-   if (cmdlen  (COMMAND_LINE_SIZE - 1))
+   if (cmdlen  (real_command_line_size - 1))
die(Command line overflow\n);
strcat(cmdline, str_mmap);
}
@@ -418,7 +448,7 @@ static int cmdline_add_elfcorehdr(char *
strcat(str, K);
len = strlen(str);
cmdlen = strlen(cmdline) + len;
-   if (cmdlen  (COMMAND_LINE_SIZE - 1))
+   if (cmdlen  (real_command_line_size - 1))
die(Command line overflow\n);
strcat(cmdline, str);
 #if 0
Index: 

Re: [Fastboot] [PATCH] Add support for longer kernel command lines (i586, x86_64, IA64)

2007-03-05 Thread Vivek Goyal
On Mon, Mar 05, 2007 at 11:34:33PM +0100, Bernhard Walle wrote:
 This patch increases the kernel command line size for x86_64 and i386
 to 2048 characters. This is necessary because with kernel 2.6.21
 and newer, the kernel command line size has increased and kexec needs
 lot of command line space, so this solves some command line overflow
 problems.
 
 To be able to warn users running older kernels that the command line
 is too long (and don't wait that the kernel truncates it), the
 patch tries to get the kernel command line length from the kernel
 image that is loaded if possible by checking the length of the
 static array that holds the kernel command line when booting.
 

It does not work for compressed images (bzImage). So kexing older bzImages
will never give you a warning message.

Secondly, I think creating dependencies on kernel symbols is bad. Tomorrow
if kernel code changes, we are broken. The problem crash faces so often.
So we should create a well defined interface which can remain constant 
even if kernel code changes.

I personally think either there should be a way to specify command line
length supported in the image format (bzImage) or we should export it to 
user space, lets say through /proc/ interface. 

Specifying max cmdline lenght in bzImage header helps because any bootloader
then take a clue and warn user about excessive command line length.

Otherwise we can export something like /proc/max_cmdline_len on the lines
of /proc/cmdline.

Thanks
Vivek
___
fastboot mailing list
fastboot@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/fastboot