Commit 8f9aeca7 authored by Bernhard Walle's avatar Bernhard Walle Committed by Andi Kleen

[PATCH] x86: add command line length to boot protocol

Because the command line is increased to 2048 characters after 2.6.21, it's
not possible for boot loaders and userspace tools to determine the length
of the command line the kernel can understand.  The benefit of knowing the
length is that users can be warned if the command line size is too long
which prevents surprise if things don't work after bootup.

This patch updates the boot protocol to contain a field called
"cmdline_size" that contain the length of the command line (excluding the
terminating zero).

The patch also adds missing fields (of protocol version 2.05) to the x86_64
setup code.
Signed-off-by: default avatarBernhard Walle <bwalle@suse.de>
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Cc: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: default avatarH. Peter Anvin <hpa@zytor.com>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 79e03011
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
---------------------------- ----------------------------
H. Peter Anvin <hpa@zytor.com> H. Peter Anvin <hpa@zytor.com>
Last update 2007-01-26 Last update 2007-03-06
On the i386 platform, the Linux kernel uses a rather complicated boot On the i386 platform, the Linux kernel uses a rather complicated boot
convention. This has evolved partially due to historical aspects, as convention. This has evolved partially due to historical aspects, as
...@@ -35,9 +35,13 @@ Protocol 2.03: (Kernel 2.4.18-pre1) Explicitly makes the highest possible ...@@ -35,9 +35,13 @@ Protocol 2.03: (Kernel 2.4.18-pre1) Explicitly makes the highest possible
initrd address available to the bootloader. initrd address available to the bootloader.
Protocol 2.04: (Kernel 2.6.14) Extend the syssize field to four bytes. Protocol 2.04: (Kernel 2.6.14) Extend the syssize field to four bytes.
Protocol 2.05: (Kernel 2.6.20) Make protected mode kernel relocatable. Protocol 2.05: (Kernel 2.6.20) Make protected mode kernel relocatable.
Introduce relocatable_kernel and kernel_alignment fields. Introduce relocatable_kernel and kernel_alignment fields.
Protocol 2.06: (Kernel 2.6.22) Added a field that contains the size of
the boot command line
**** MEMORY LAYOUT **** MEMORY LAYOUT
...@@ -133,6 +137,8 @@ Offset Proto Name Meaning ...@@ -133,6 +137,8 @@ Offset Proto Name Meaning
022C/4 2.03+ initrd_addr_max Highest legal initrd address 022C/4 2.03+ initrd_addr_max Highest legal initrd address
0230/4 2.05+ kernel_alignment Physical addr alignment required for kernel 0230/4 2.05+ kernel_alignment Physical addr alignment required for kernel
0234/1 2.05+ relocatable_kernel Whether kernel is relocatable or not 0234/1 2.05+ relocatable_kernel Whether kernel is relocatable or not
0235/3 N/A pad2 Unused
0238/4 2.06+ cmdline_size Maximum size of the kernel command line
(1) For backwards compatibility, if the setup_sects field contains 0, the (1) For backwards compatibility, if the setup_sects field contains 0, the
real value is 4. real value is 4.
...@@ -233,6 +239,12 @@ filled out, however: ...@@ -233,6 +239,12 @@ filled out, however:
if your ramdisk is exactly 131072 bytes long and this field is if your ramdisk is exactly 131072 bytes long and this field is
0x37FFFFFF, you can start your ramdisk at 0x37FE0000.) 0x37FFFFFF, you can start your ramdisk at 0x37FE0000.)
cmdline_size:
The maximum size of the command line without the terminating
zero. This means that the command line can contain at most
cmdline_size characters. With protocol version 2.05 and
earlier, the maximum size was 255.
**** THE KERNEL COMMAND LINE **** THE KERNEL COMMAND LINE
...@@ -241,11 +253,10 @@ loader to communicate with the kernel. Some of its options are also ...@@ -241,11 +253,10 @@ loader to communicate with the kernel. Some of its options are also
relevant to the boot loader itself, see "special command line options" relevant to the boot loader itself, see "special command line options"
below. below.
The kernel command line is a null-terminated string currently up to The kernel command line is a null-terminated string. The maximum
255 characters long, plus the final null. A string that is too long length can be retrieved from the field cmdline_size. Before protocol
will be automatically truncated by the kernel, a boot loader may allow version 2.06, the maximum was 255 characters. A string that is too
a longer command line to be passed to permit future kernels to extend long will be automatically truncated by the kernel.
this limit.
If the boot protocol version is 2.02 or later, the address of the If the boot protocol version is 2.02 or later, the address of the
kernel command line is given by the header field cmd_line_ptr (see kernel command line is given by the header field cmd_line_ptr (see
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include <asm/boot.h> #include <asm/boot.h>
#include <asm/e820.h> #include <asm/e820.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/setup.h>
/* Signature words to ensure LILO loaded us right */ /* Signature words to ensure LILO loaded us right */
#define SIG1 0xAA55 #define SIG1 0xAA55
...@@ -81,7 +82,7 @@ start: ...@@ -81,7 +82,7 @@ start:
# This is the setup header, and it must start at %cs:2 (old 0x9020:2) # This is the setup header, and it must start at %cs:2 (old 0x9020:2)
.ascii "HdrS" # header signature .ascii "HdrS" # header signature
.word 0x0205 # header version number (>= 0x0105) .word 0x0206 # header version number (>= 0x0105)
# or else old loadlin-1.5 will fail) # or else old loadlin-1.5 will fail)
realmode_swtch: .word 0, 0 # default_switch, SETUPSEG realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
start_sys_seg: .word SYSSEG start_sys_seg: .word SYSSEG
...@@ -171,6 +172,10 @@ relocatable_kernel: .byte 0 ...@@ -171,6 +172,10 @@ relocatable_kernel: .byte 0
pad2: .byte 0 pad2: .byte 0
pad3: .word 0 pad3: .word 0
cmdline_size: .long COMMAND_LINE_SIZE-1 #length of the command line,
#added with boot protocol
#version 2.06
trampoline: call start_of_setup trampoline: call start_of_setup
.align 16 .align 16
# The offset at this point is 0x240 # The offset at this point is 0x240
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include <asm/boot.h> #include <asm/boot.h>
#include <asm/e820.h> #include <asm/e820.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/setup.h>
/* Signature words to ensure LILO loaded us right */ /* Signature words to ensure LILO loaded us right */
#define SIG1 0xAA55 #define SIG1 0xAA55
...@@ -80,7 +81,7 @@ start: ...@@ -80,7 +81,7 @@ start:
# This is the setup header, and it must start at %cs:2 (old 0x9020:2) # This is the setup header, and it must start at %cs:2 (old 0x9020:2)
.ascii "HdrS" # header signature .ascii "HdrS" # header signature
.word 0x0205 # header version number (>= 0x0105) .word 0x0206 # header version number (>= 0x0105)
# or else old loadlin-1.5 will fail) # or else old loadlin-1.5 will fail)
realmode_swtch: .word 0, 0 # default_switch, SETUPSEG realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
start_sys_seg: .word SYSSEG start_sys_seg: .word SYSSEG
...@@ -165,6 +166,10 @@ relocatable_kernel: .byte 0 ...@@ -165,6 +166,10 @@ relocatable_kernel: .byte 0
pad2: .byte 0 pad2: .byte 0
pad3: .word 0 pad3: .word 0
cmdline_size: .long COMMAND_LINE_SIZE-1 #length of the command line,
#added with boot protocol
#version 2.06
trampoline: call start_of_setup trampoline: call start_of_setup
.align 16 .align 16
# The offset at this point is 0x240 # The offset at this point is 0x240
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment