[syslinux] [syslinux:firmware] load_linux: dynamically calculate the cmdline region
Matt Fleming
matt at console-pimps.org
Tue Jul 30 08:10:45 PDT 2013
On Mon, 29 Jul, at 06:49:33AM, H. Peter Anvin wrote:
> If the kernel is loaded high, for kernel >= 2.00 the real mode code can
> be anywhere... but the cmdline needs to lie inside the real-mode segment
> (in particular in the range covered by setup_move_size). However, these
> kernels, at least for actual Liux, would then still move stuff up to the
> 0x90000 segment... in large measure defeating the point of loading low.
> It does it pretty late, though, so one can argue that some amount of
> overwrite is probably okay. Probably.
Does something like this seem reasonable? It assumes that 0xa0000 is
still a hard upper limit.
(Sorry, it's a patch against changes that fix the SMT_FREE vs.
SMT_TERMINAL issue)
---
diff --git a/com32/lib/syslinux/load_linux.c b/com32/lib/syslinux/load_linux.c
index a1cda01..deedb37 100644
--- a/com32/lib/syslinux/load_linux.c
+++ b/com32/lib/syslinux/load_linux.c
@@ -130,16 +130,21 @@ static size_t calc_cmdline_offset(struct linux_header *hdr,
{
if (hdr->version < 0x0202 || !(hdr->loadflags & 0x01)) {
struct syslinux_memmap *mmap;
+ addr_t ceiling;
int rv1, rv2;
mmap = syslinux_memory_map();
if (!mmap)
goto bail;
+ ceiling = (base + (64 << 10)) & 0xffff0000;
+ if (ceiling > 0xa0000)
+ ceiling = 0xa0000;
+
rv1 = syslinux_memmap_highest(mmap, SMT_FREE, &start,
- cmdline_size, 0xa0000, 16);
+ cmdline_size, ceiling, 16);
rv2 = syslinux_memmap_highest(mmap, SMT_TERMINAL, &start,
- cmdline_size, 0xa0000, 16);
+ cmdline_size, ceiling, 16);
syslinux_free_memmap(mmap);
if (rv1 && rv2)
--
Matt Fleming, Intel Open Source Technology Center
More information about the Syslinux
mailing list