瀏覽代碼

[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>
tags/v1.20.1
Michael Brown 11 年之前
父節點
當前提交
747e9eb6f3
共有 1 個檔案被更改,包括 10 行新增3 行删除
  1. 10
    3
      src/arch/i386/prefix/lkrnprefix.S

+ 10
- 3
src/arch/i386/prefix/lkrnprefix.S 查看文件

@@ -231,9 +231,12 @@ run_ipxe:
231 231
 	movzwl	%sp, %edx
232 232
 no_cmd_line:
233 233
 
234
-	/* Retrieve initrd pointer and size */
235
-	movl	%ds:ramdisk_image, %ebp
236
-	movl	%ds:ramdisk_size, %ecx
234
+	/* Calculate maximum relocation address */
235
+	movl	ramdisk_image, %ebp
236
+	testl	%ebp, %ebp
237
+	jnz	1f
238
+	orl	$0xffffffff, %ebp /* Allow arbitrary relocation if no initrd */
239
+1:
237 240
 
238 241
 	/* Install iPXE */
239 242
 	call	alloc_basemem
@@ -251,6 +254,10 @@ no_cmd_line:
251 254
 	lret
252 255
 	.section ".text16", "awx", @progbits
253 256
 1:
257
+	/* Retrieve initrd pointer and size */
258
+	movl	ramdisk_image, %ebp
259
+	movl	ramdisk_size, %ecx
260
+
254 261
 	/* Set up %ds for access to .data16 */
255 262
 	movw	%bx, %ds
256 263
 

Loading…
取消
儲存