[syslinux] [syslinux:firmware] load_linux: dynamically calculate the cmdline region

H. Peter Anvin hpa at zytor.com
Fri Jul 26 09:49:28 PDT 2013


On 07/26/2013 01:27 AM, syslinux-bot for Matt Fleming wrote:
> diff --git a/com32/lib/syslinux/load_linux.c b/com32/lib/syslinux/load_linux.c
> index 851d467..37c8df0 100644
> --- a/com32/lib/syslinux/load_linux.c
> +++ b/com32/lib/syslinux/load_linux.c
> @@ -125,10 +125,29 @@ static int map_initramfs(struct syslinux_movelist **fraglist,
>  }
>  
>  static size_t calc_cmdline_offset(struct linux_header *hdr,
> -				  size_t cmdline_size)
> +				  size_t cmdline_size, addr_t base,
> +				  addr_t start)
>  {
> -    if (hdr->version < 0x0202 || !(hdr->loadflags & 0x01))
> +    if (hdr->version < 0x0202 || !(hdr->loadflags & 0x01)) {
> +	struct syslinux_memmap *mmap;
> +
> +	mmap = syslinux_memory_map();
> +	if (mmap && !syslinux_memmap_highest(mmap, SMT_FREE, &start,
> +					     cmdline_size, 0xa0000, 16)) {
> +	    syslinux_free_memmap(mmap);
> +	    return start - base;
> +	}
> +
> +	if (mmap && !syslinux_memmap_highest(mmap, SMT_TERMINAL, &start,
> +					     cmdline_size, 0xa0000, 16)) {
> +	    syslinux_free_memmap(mmap);
> +	    return start - base;
> +	}
> +

Hmm... this might constrain the heap excessively if the SMT_TERMINAL
cutoff is at the wrong place (because there will be just enough SMT_FREE
to fit.)  I'm wondering if we shouldn't use the highest of these two
regions.

Now, for old kernels, there is an additional constraint, which is that
the cmdline needs to be part of the same segment as the real mode code,
so the above is incorrect for the case of 2.00 or 2.01 kernels loaded
high, when the real mode code is loaded low... if we get an address
above real_mode_base + 64K those kernels will fail.  2.02+ kernels do
not have that limitation.

	-hpa




More information about the Syslinux mailing list