Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[lkrnprefix] Allow relocation when no initrd is present
Commit 2629b7e ("[pcbios] Inhibit all calls to INT 15,e820 and INT
15,e801 during POST") introduced a regression into .lkrn images when
used with no corresponding initrd.

Specifically, the semantics of the "maximum address for relocation"
value passed to install_prealloc() in %ebp changed so that zero became
a special value meaning "inhibit use of INT 15,e820 and INT 15,e801".
The %ebp value meaing "no upper limit on relocation" was changed from
zero to 0xffffffff, and all prefixes providing fixed values for %ebp
were updated to match the new semantics.

The .lkrn prefix provides the initrd base address as the maximum
address for relocation.  When no initrd is present, this address will
be zero, and so will unintentionally trigger the "inhibit INT 15,e820
and INT 15,e801" behaviour.

Fix by explicitly setting %ebp to 0xffffffff if no initrd is present
before calling install_prealloc().

Reported-by: Ján ONDREJ (SAL) <ondrejj@salstar.sk>
Tested-by: Ján ONDREJ (SAL) <ondrejj@salstar.sk>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Mar 15, 2013
1 parent e63f6c9 commit 747e9eb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/arch/i386/prefix/lkrnprefix.S
Expand Up @@ -231,9 +231,12 @@ run_ipxe:
movzwl %sp, %edx
no_cmd_line:

/* Retrieve initrd pointer and size */
movl %ds:ramdisk_image, %ebp
movl %ds:ramdisk_size, %ecx
/* Calculate maximum relocation address */
movl ramdisk_image, %ebp
testl %ebp, %ebp
jnz 1f
orl $0xffffffff, %ebp /* Allow arbitrary relocation if no initrd */
1:

/* Install iPXE */
call alloc_basemem
Expand All @@ -251,6 +254,10 @@ no_cmd_line:
lret
.section ".text16", "awx", @progbits
1:
/* Retrieve initrd pointer and size */
movl ramdisk_image, %ebp
movl ramdisk_size, %ecx

/* Set up %ds for access to .data16 */
movw %bx, %ds

Expand Down

0 comments on commit 747e9eb

Please sign in to comment.