diff options
author | Bernhard Walle <bwalle@suse.de> | 2007-05-02 13:27:10 -0400 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2007-05-02 13:27:10 -0400 |
commit | 8f9aeca7a081d81c4c9862be1e04f15b5ab5461f (patch) | |
tree | 49b802b90aca5b170aba5734ef99344a90426b01 | |
parent | 79e030114a8d97a1dcd593ab84fb986f8c91c536 (diff) |
[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: Bernhard Walle <bwalle@suse.de>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Alon Bar-Lev <alon.barlev@gmail.com>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r-- | Documentation/i386/boot.txt | 23 | ||||
-rw-r--r-- | arch/i386/boot/setup.S | 7 | ||||
-rw-r--r-- | arch/x86_64/boot/setup.S | 7 |
3 files changed, 29 insertions, 8 deletions
diff --git a/Documentation/i386/boot.txt b/Documentation/i386/boot.txt index 38fe1f03fb14..6498666ea330 100644 --- a/Documentation/i386/boot.txt +++ b/Documentation/i386/boot.txt | |||
@@ -2,7 +2,7 @@ | |||
2 | ---------------------------- | 2 | ---------------------------- |
3 | 3 | ||
4 | H. Peter Anvin <hpa@zytor.com> | 4 | H. Peter Anvin <hpa@zytor.com> |
5 | Last update 2007-01-26 | 5 | Last update 2007-03-06 |
6 | 6 | ||
7 | On the i386 platform, the Linux kernel uses a rather complicated boot | 7 | On the i386 platform, the Linux kernel uses a rather complicated boot |
8 | convention. This has evolved partially due to historical aspects, as | 8 | 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 | initrd address available to the bootloader. | 35 | initrd address available to the bootloader. |
36 | 36 | ||
37 | Protocol 2.04: (Kernel 2.6.14) Extend the syssize field to four bytes. | 37 | Protocol 2.04: (Kernel 2.6.14) Extend the syssize field to four bytes. |
38 | |||
38 | Protocol 2.05: (Kernel 2.6.20) Make protected mode kernel relocatable. | 39 | Protocol 2.05: (Kernel 2.6.20) Make protected mode kernel relocatable. |
39 | Introduce relocatable_kernel and kernel_alignment fields. | 40 | Introduce relocatable_kernel and kernel_alignment fields. |
40 | 41 | ||
42 | Protocol 2.06: (Kernel 2.6.22) Added a field that contains the size of | ||
43 | the boot command line | ||
44 | |||
41 | 45 | ||
42 | **** MEMORY LAYOUT | 46 | **** MEMORY LAYOUT |
43 | 47 | ||
@@ -133,6 +137,8 @@ Offset Proto Name Meaning | |||
133 | 022C/4 2.03+ initrd_addr_max Highest legal initrd address | 137 | 022C/4 2.03+ initrd_addr_max Highest legal initrd address |
134 | 0230/4 2.05+ kernel_alignment Physical addr alignment required for kernel | 138 | 0230/4 2.05+ kernel_alignment Physical addr alignment required for kernel |
135 | 0234/1 2.05+ relocatable_kernel Whether kernel is relocatable or not | 139 | 0234/1 2.05+ relocatable_kernel Whether kernel is relocatable or not |
140 | 0235/3 N/A pad2 Unused | ||
141 | 0238/4 2.06+ cmdline_size Maximum size of the kernel command line | ||
136 | 142 | ||
137 | (1) For backwards compatibility, if the setup_sects field contains 0, the | 143 | (1) For backwards compatibility, if the setup_sects field contains 0, the |
138 | real value is 4. | 144 | real value is 4. |
@@ -233,6 +239,12 @@ filled out, however: | |||
233 | if your ramdisk is exactly 131072 bytes long and this field is | 239 | if your ramdisk is exactly 131072 bytes long and this field is |
234 | 0x37FFFFFF, you can start your ramdisk at 0x37FE0000.) | 240 | 0x37FFFFFF, you can start your ramdisk at 0x37FE0000.) |
235 | 241 | ||
242 | cmdline_size: | ||
243 | The maximum size of the command line without the terminating | ||
244 | zero. This means that the command line can contain at most | ||
245 | cmdline_size characters. With protocol version 2.05 and | ||
246 | earlier, the maximum size was 255. | ||
247 | |||
236 | 248 | ||
237 | **** THE KERNEL COMMAND LINE | 249 | **** THE KERNEL COMMAND LINE |
238 | 250 | ||
@@ -241,11 +253,10 @@ loader to communicate with the kernel. Some of its options are also | |||
241 | relevant to the boot loader itself, see "special command line options" | 253 | relevant to the boot loader itself, see "special command line options" |
242 | below. | 254 | below. |
243 | 255 | ||
244 | The kernel command line is a null-terminated string currently up to | 256 | The kernel command line is a null-terminated string. The maximum |
245 | 255 characters long, plus the final null. A string that is too long | 257 | length can be retrieved from the field cmdline_size. Before protocol |
246 | will be automatically truncated by the kernel, a boot loader may allow | 258 | version 2.06, the maximum was 255 characters. A string that is too |
247 | a longer command line to be passed to permit future kernels to extend | 259 | long will be automatically truncated by the kernel. |
248 | this limit. | ||
249 | 260 | ||
250 | If the boot protocol version is 2.02 or later, the address of the | 261 | If the boot protocol version is 2.02 or later, the address of the |
251 | kernel command line is given by the header field cmd_line_ptr (see | 262 | kernel command line is given by the header field cmd_line_ptr (see |
diff --git a/arch/i386/boot/setup.S b/arch/i386/boot/setup.S index 06edf1c66242..b74b7f40b79c 100644 --- a/arch/i386/boot/setup.S +++ b/arch/i386/boot/setup.S | |||
@@ -52,6 +52,7 @@ | |||
52 | #include <asm/boot.h> | 52 | #include <asm/boot.h> |
53 | #include <asm/e820.h> | 53 | #include <asm/e820.h> |
54 | #include <asm/page.h> | 54 | #include <asm/page.h> |
55 | #include <asm/setup.h> | ||
55 | 56 | ||
56 | /* Signature words to ensure LILO loaded us right */ | 57 | /* Signature words to ensure LILO loaded us right */ |
57 | #define SIG1 0xAA55 | 58 | #define SIG1 0xAA55 |
@@ -81,7 +82,7 @@ start: | |||
81 | # This is the setup header, and it must start at %cs:2 (old 0x9020:2) | 82 | # This is the setup header, and it must start at %cs:2 (old 0x9020:2) |
82 | 83 | ||
83 | .ascii "HdrS" # header signature | 84 | .ascii "HdrS" # header signature |
84 | .word 0x0205 # header version number (>= 0x0105) | 85 | .word 0x0206 # header version number (>= 0x0105) |
85 | # or else old loadlin-1.5 will fail) | 86 | # or else old loadlin-1.5 will fail) |
86 | realmode_swtch: .word 0, 0 # default_switch, SETUPSEG | 87 | realmode_swtch: .word 0, 0 # default_switch, SETUPSEG |
87 | start_sys_seg: .word SYSSEG | 88 | start_sys_seg: .word SYSSEG |
@@ -171,6 +172,10 @@ relocatable_kernel: .byte 0 | |||
171 | pad2: .byte 0 | 172 | pad2: .byte 0 |
172 | pad3: .word 0 | 173 | pad3: .word 0 |
173 | 174 | ||
175 | cmdline_size: .long COMMAND_LINE_SIZE-1 #length of the command line, | ||
176 | #added with boot protocol | ||
177 | #version 2.06 | ||
178 | |||
174 | trampoline: call start_of_setup | 179 | trampoline: call start_of_setup |
175 | .align 16 | 180 | .align 16 |
176 | # The offset at this point is 0x240 | 181 | # The offset at this point is 0x240 |
diff --git a/arch/x86_64/boot/setup.S b/arch/x86_64/boot/setup.S index 816d04faa2be..4f8851000d7e 100644 --- a/arch/x86_64/boot/setup.S +++ b/arch/x86_64/boot/setup.S | |||
@@ -51,6 +51,7 @@ | |||
51 | #include <asm/boot.h> | 51 | #include <asm/boot.h> |
52 | #include <asm/e820.h> | 52 | #include <asm/e820.h> |
53 | #include <asm/page.h> | 53 | #include <asm/page.h> |
54 | #include <asm/setup.h> | ||
54 | 55 | ||
55 | /* Signature words to ensure LILO loaded us right */ | 56 | /* Signature words to ensure LILO loaded us right */ |
56 | #define SIG1 0xAA55 | 57 | #define SIG1 0xAA55 |
@@ -80,7 +81,7 @@ start: | |||
80 | # This is the setup header, and it must start at %cs:2 (old 0x9020:2) | 81 | # This is the setup header, and it must start at %cs:2 (old 0x9020:2) |
81 | 82 | ||
82 | .ascii "HdrS" # header signature | 83 | .ascii "HdrS" # header signature |
83 | .word 0x0205 # header version number (>= 0x0105) | 84 | .word 0x0206 # header version number (>= 0x0105) |
84 | # or else old loadlin-1.5 will fail) | 85 | # or else old loadlin-1.5 will fail) |
85 | realmode_swtch: .word 0, 0 # default_switch, SETUPSEG | 86 | realmode_swtch: .word 0, 0 # default_switch, SETUPSEG |
86 | start_sys_seg: .word SYSSEG | 87 | start_sys_seg: .word SYSSEG |
@@ -165,6 +166,10 @@ relocatable_kernel: .byte 0 | |||
165 | pad2: .byte 0 | 166 | pad2: .byte 0 |
166 | pad3: .word 0 | 167 | pad3: .word 0 |
167 | 168 | ||
169 | cmdline_size: .long COMMAND_LINE_SIZE-1 #length of the command line, | ||
170 | #added with boot protocol | ||
171 | #version 2.06 | ||
172 | |||
168 | trampoline: call start_of_setup | 173 | trampoline: call start_of_setup |
169 | .align 16 | 174 | .align 16 |
170 | # The offset at this point is 0x240 | 175 | # The offset at this point is 0x240 |