2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-11-26 03:09:12 +00:00

[pxeprefix] Place temporary stack after iPXE binary

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>
This commit is contained in:
Michael Brown 2012-07-10 16:10:49 +01:00
parent 9f0b2d25a8
commit 9e5152e095

View 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
*****************************************************************************