Blame 0004-Obey-2.06-boot-protocol-s-cmdline_size.patch

91d7307
From cbb7e3d28164467b104814484965d30333d529ba Mon Sep 17 00:00:00 2001
91d7307
From: Lubomir Rintel <lkundrak@v3.sk>
91d7307
Date: Sun, 11 Jan 2009 12:04:10 +0100
91d7307
Subject: [PATCH] Obey 2.06 boot protocol's cmdline_size
91d7307
91d7307
This increases the limit for the command line according to kernel's
91d7307
setting, up to 0x7FF characters. This limit was chosen because it
91d7307
matches current kernel's limitation and doesn't need substantial
91d7307
change in memory layout, consuming only spare space (and leaving
91d7307
once as much bytes spare for possible future expansion).
91d7307
91d7307
Bug Report: https://bugzilla.redhat.com/attachment.cgi?id=327541
91d7307
---
91d7307
 stage2/boot.c   |   13 +++++++++++--
91d7307
 stage2/shared.h |    7 +++++--
91d7307
 2 files changed, 16 insertions(+), 4 deletions(-)
91d7307
91d7307
diff --git a/stage2/boot.c b/stage2/boot.c
91d7307
index eee8bb1..2267721 100644
91d7307
--- a/stage2/boot.c
91d7307
+++ b/stage2/boot.c
91d7307
@@ -228,6 +228,7 @@ load_image (char *kernel, char *arg, kernel_t suggested_type,
91d7307
     {
91d7307
       int big_linux = 0;
91d7307
       int setup_sects = lh->setup_sects;
91d7307
+      int cmdline_size = 0xff;
91d7307
 
91d7307
       if (lh->header == LINUX_MAGIC_SIGNATURE && lh->version >= 0x0200)
91d7307
 	{
91d7307
@@ -255,6 +256,14 @@ load_image (char *kernel, char *arg, kernel_t suggested_type,
91d7307
 	      lh->cl_offset = LINUX_CL_OFFSET;
91d7307
 	      lh->setup_move_size = LINUX_SETUP_MOVE_SIZE;
91d7307
 	    }
91d7307
+
91d7307
+	  if (lh->version >= 0x0206)
91d7307
+	    {
91d7307
+	      cmdline_size = lh->cmdline_size;
91d7307
+	      if (cmdline_size > (LINUX_CL_END_OFFSET - LINUX_CL_OFFSET))
91d7307
+		cmdline_size = LINUX_CL_END_OFFSET - LINUX_CL_OFFSET;
91d7307
+	    }
91d7307
+
91d7307
 	}
91d7307
       else
91d7307
 	{
91d7307
@@ -411,7 +420,7 @@ load_image (char *kernel, char *arg, kernel_t suggested_type,
91d7307
 	    char *src = skip_to (0, arg);
91d7307
 	    char *dest = linux_data_tmp_addr + LINUX_CL_OFFSET;
91d7307
 	
91d7307
-	    while (dest < linux_data_tmp_addr + LINUX_CL_END_OFFSET && *src)
91d7307
+	    while (dest < linux_data_tmp_addr + LINUX_CL_OFFSET + cmdline_size && *src)
91d7307
 	      *(dest++) = *(src++);
91d7307
 	
91d7307
 	    /* Old Linux kernels have problems determining the amount of
91d7307
@@ -432,7 +441,7 @@ load_image (char *kernel, char *arg, kernel_t suggested_type,
91d7307
 	    if (! grub_strstr (arg, "mem=")
91d7307
 		&& ! (load_flags & KERNEL_LOAD_NO_MEM_OPTION)
91d7307
 		&& lh->version < 0x0203		/* kernel version < 2.4.18 */
91d7307
-		&& dest + 15 < linux_data_tmp_addr + LINUX_CL_END_OFFSET)
91d7307
+		&& dest + 15 < linux_data_tmp_addr + LINUX_CL_OFFSET + cmdline_size)
91d7307
 	      {
91d7307
 		*dest++ = ' ';
91d7307
 		*dest++ = 'm';
91d7307
diff --git a/stage2/shared.h b/stage2/shared.h
91d7307
index 93f586f..49711af 100644
91d7307
--- a/stage2/shared.h
91d7307
+++ b/stage2/shared.h
91d7307
@@ -162,8 +162,8 @@ extern void *grub_scratch_mem;
91d7307
 #define LINUX_VID_MODE_ASK		0xFFFD
91d7307
 
91d7307
 #define LINUX_CL_OFFSET			0x9000
91d7307
-#define LINUX_CL_END_OFFSET		0x90FF
91d7307
-#define LINUX_SETUP_MOVE_SIZE		0x9100
91d7307
+#define LINUX_CL_END_OFFSET		0x97FF
91d7307
+#define LINUX_SETUP_MOVE_SIZE		0x9800
91d7307
 #define LINUX_CL_MAGIC			0xA33F
91d7307
 
91d7307
 /*
91d7307
@@ -423,6 +423,9 @@ struct linux_kernel_header
91d7307
   unsigned short pad1;			/* Unused */
91d7307
   char *cmd_line_ptr;			/* Points to the kernel command line */
91d7307
   unsigned int initrd_addr_max;		/* The highest address of initrd */
91d7307
+  unsigned int kernel_alignment;	/* Physical addr alignment required for kernel */
91d7307
+  unsigned int relocatable_kernel;	/* Whether kernel is relocatable or not */
91d7307
+  unsigned int cmdline_size;		/* Maximum size of the kernel command line */
91d7307
 } __attribute__ ((packed));
91d7307
 
91d7307
 /* Memory map address range descriptor used by GET_MMAP_ENTRY. */
91d7307
-- 
91d7307
1.5.5.6
91d7307