Browse Source

[bzimage] Support kernel command lines of greater than 256 characters

2.6.22+ kernels have an extra field in the bzimage_header structure to
indicate the maximum permitted command-line length.  Use this if it is
available.
tags/v0.9.4
Michael Brown 16 years ago
parent
commit
ac28d054c8
2 changed files with 18 additions and 2 deletions
  1. 10
    2
      src/arch/i386/image/bzimage.c
  2. 8
    0
      src/arch/i386/include/bzimage.h

+ 10
- 2
src/arch/i386/image/bzimage.c View File

@@ -76,6 +76,8 @@ struct bzimage_exec_context {
76 76
 	size_t rm_heap;
77 77
 	/** Command line (offset from rm_kernel) */
78 78
 	size_t rm_cmdline;
79
+	/** Command line maximum length */
80
+	size_t cmdline_size;
79 81
 	/** Video mode */
80 82
 	unsigned int vid_mode;
81 83
 	/** Memory limit */
@@ -162,8 +164,8 @@ static int bzimage_set_cmdline ( struct image *image,
162 164
 
163 165
 	/* Copy command line down to real-mode portion */
164 166
 	cmdline_len = ( strlen ( cmdline ) + 1 );
165
-	if ( cmdline_len > BZI_CMDLINE_SIZE )
166
-		cmdline_len = BZI_CMDLINE_SIZE;
167
+	if ( cmdline_len > exec_ctx->cmdline_size )
168
+		cmdline_len = exec_ctx->cmdline_size;
167 169
 	copy_to_user ( exec_ctx->rm_kernel, exec_ctx->rm_cmdline,
168 170
 		       cmdline, cmdline_len );
169 171
 	DBGC ( image, "bzImage %p command line \"%s\"\n", image, cmdline );
@@ -320,6 +322,12 @@ static int bzimage_exec ( struct image *image ) {
320 322
 	} else {
321 323
 		exec_ctx.mem_limit = BZI_INITRD_MAX;
322 324
 	}
325
+	if ( bzhdr.version >= 0x0206 ) {
326
+		exec_ctx.cmdline_size = bzhdr.cmdline_size;
327
+	} else {
328
+		exec_ctx.cmdline_size = BZI_CMDLINE_SIZE;
329
+	}
330
+	DBG ( "cmdline_size = %zd\n", exec_ctx.cmdline_size );
323 331
 
324 332
 	/* Parse command line for bootloader parameters */
325 333
 	if ( ( rc = bzimage_parse_cmdline ( image, &exec_ctx, cmdline ) ) != 0)

+ 8
- 0
src/arch/i386/include/bzimage.h View File

@@ -62,6 +62,14 @@ struct bzimage_header {
62 62
 	uint32_t cmd_line_ptr;
63 63
 	/** Highest legal initrd address */
64 64
 	uint32_t initrd_addr_max;
65
+	/** Physical addr alignment required for kernel	*/
66
+	uint32_t kernel_alignment;
67
+	/** Whether kernel is relocatable or not */
68
+	uint8_t relocatable_kernel;
69
+	/** Unused */
70
+	uint8_t pad2[3];
71
+	/** Maximum size of the kernel command line */
72
+	uint32_t cmdline_size;
65 73
 } __attribute__ (( packed ));
66 74
 
67 75
 /** Offset of bzImage header within kernel image */

Loading…
Cancel
Save