aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2013-02-04 11:35:39 -0800
committerH. Peter Anvin <hpa@linux.intel.com>2013-02-04 11:35:39 -0800
commitc3b4e4408688d150da5da74b15b5dba773ff3f28 (patch)
tree5f126bf242437727031f75579d9bff3e2612413f
parentb9911b669ba6c0118431df0675ba4df14abb21d8 (diff)
downloadsyslinux-c3b4e4408688d150da5da74b15b5dba773ff3f28.tar.gz
syslinux-c3b4e4408688d150da5da74b15b5dba773ff3f28.tar.xz
syslinux-c3b4e4408688d150da5da74b15b5dba773ff3f28.zip
load_linux: additional cleanups and corner case fixing
Handle the case with a zero-length passed in initramfs for ancient protocols, since we bothered handling it correctly for newer protocols. Move the setting of the command line pointer to the place where the command line is actually placed, for clarity. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--com32/lib/syslinux/load_linux.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/com32/lib/syslinux/load_linux.c b/com32/lib/syslinux/load_linux.c
index f70682f0..f67c2e4f 100644
--- a/com32/lib/syslinux/load_linux.c
+++ b/com32/lib/syslinux/load_linux.c
@@ -290,7 +290,10 @@ int syslinux_boot_linux(void *kernel_buf, size_t kernel_size,
if (!(hdr.loadflags & LOAD_HIGH) && prot_mode_size > 512 * 1024)
goto bail; /* Kernel cannot be loaded low */
- if (initramfs && hdr.version < 0x0200)
+ /* Get the size of the initramfs, if there is one */
+ irf_size = initramfs_size(initramfs);
+
+ if (irf_size && hdr.version < 0x0200)
goto bail; /* initrd/initramfs not supported */
if (hdr.version >= 0x0200) {
@@ -389,18 +392,6 @@ int syslinux_boot_linux(void *kernel_buf, size_t kernel_size,
}
}
- /* Set up the command line information in the header */
- if (hdr.version >= 0x0202) {
- whdr->cmd_line_ptr = real_mode_base + cmdline_offset;
- } else {
- whdr->old_cmd_line_magic = OLD_CMDLINE_MAGIC;
- whdr->old_cmd_line_offset = cmdline_offset;
- if (hdr.version >= 0x0200) {
- /* Be paranoid and round up to a multiple of 16 */
- whdr->setup_move_size = (cmdline_offset + cmdline_size + 15) & ~15;
- }
- }
-
if (syslinux_add_movelist(&fraglist, real_mode_base, (addr_t) kernel_buf,
real_mode_size))
goto bail;
@@ -417,6 +408,16 @@ int syslinux_boot_linux(void *kernel_buf, size_t kernel_size,
if (syslinux_add_movelist(&fraglist, real_mode_base + cmdline_offset,
(addr_t) cmdline, cmdline_size))
goto bail;
+ if (hdr.version >= 0x0202) {
+ whdr->cmd_line_ptr = real_mode_base + cmdline_offset;
+ } else {
+ whdr->old_cmd_line_magic = OLD_CMDLINE_MAGIC;
+ whdr->old_cmd_line_offset = cmdline_offset;
+ if (hdr.version >= 0x0200) {
+ /* Be paranoid and round up to a multiple of 16 */
+ whdr->setup_move_size = (cmdline_offset + cmdline_size + 15) & ~15;
+ }
+ }
/* Protected-mode code */
if (syslinux_add_movelist(&fraglist, prot_mode_base,
@@ -430,8 +431,6 @@ int syslinux_boot_linux(void *kernel_buf, size_t kernel_size,
We should put it at the highest possible address which is
<= hdr.initrd_addr_max, which fits the entire initramfs. */
- irf_size = initramfs_size(initramfs); /* Handles initramfs == NULL */
-
if (irf_size) {
addr_t best_addr = 0;
struct syslinux_memmap *ml;