]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[pxeprefix] Place temporary stack after iPXE binary
authorMichael Brown <mcb30@ipxe.org>
Tue, 10 Jul 2012 15:10:49 +0000 (16:10 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 10 Jul 2012 15:10:49 +0000 (16:10 +0100)
Some BIOSes (observed on a Supermicro system with an AMI BIOS) seem to
use the area immediately below 0x7c00 to store data related to the
boot process.  This data is currently liable to be overwritten by the
temporary stack used while decompressing and installing iPXE.

Try to avoid any such problems by placing the temporary stack
immediately after the loaded iPXE binary.  Any memory used by the
stack could then potentially have been overwritten anyway by a larger
binary.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/i386/prefix/pxeprefix.S

index f59e347ad20dfacdaaff8ac4c9ed689435b18f92..9ccc4a2b519a31fd19a1dcbfb9d29a4b1b2d9b73 100644 (file)
@@ -19,6 +19,8 @@ FILE_LICENCE ( GPL2_OR_LATER )
 #define EB_MAGIC_1 ( 'E' + ( 't' << 8 ) + ( 'h' << 16 ) + ( 'e' << 24 ) )
 #define EB_MAGIC_2 ( 'r' + ( 'b' << 8 ) + ( 'o' << 16 ) + ( 'o' << 24 ) )
 
+#define PREFIX_STACK_SIZE 2048
+
 /*****************************************************************************
  * Entry point:        set operating context, print welcome message
  *****************************************************************************
@@ -46,10 +48,11 @@ _pxe_start:
        movw    %ax, %ds
        movw    $0x40, %ax              /* BIOS data segment access */
        movw    %ax, %fs
-       /* Set up stack just below 0x7c00 */
-       xorw    %ax, %ax
+       /* Set up temporary stack immediately after the iPXE image */
+       movw    %cs, %ax
+       addw    image_size_pgh, %ax
        movw    %ax, %ss
-       movl    $0x7c00, %esp
+       movl    $PREFIX_STACK_SIZE, %esp
        /* Clear direction flag, for the sake of sanity */
        cld
        /* Print welcome message */
@@ -60,6 +63,18 @@ _pxe_start:
 10:    .asciz  "PXE->EB:"
        .previous
 
+       /* Image size (for stack placement calculation) */
+       .section ".prefix.data", "aw", @progbits
+image_size_pgh:
+       .word   0
+       .previous
+       .section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
+       .ascii  "ADDW"
+       .long   image_size_pgh
+       .long   16
+       .long   0
+       .previous
+
 /*****************************************************************************
  * Find us a usable !PXE or PXENV+ entry point
  *****************************************************************************