From 747e9eb6f39c4e755b5f3ed0cbc82e1d04b0124a Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 15 Mar 2013 15:22:57 +0000 Subject: [PATCH] [lkrnprefix] Allow relocation when no initrd is present MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) Tested-by: Ján ONDREJ (SAL) Signed-off-by: Michael Brown --- src/arch/i386/prefix/lkrnprefix.S | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/arch/i386/prefix/lkrnprefix.S b/src/arch/i386/prefix/lkrnprefix.S index 76890332..690031f0 100644 --- a/src/arch/i386/prefix/lkrnprefix.S +++ b/src/arch/i386/prefix/lkrnprefix.S @@ -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 @@ -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