[syslinux:master] pxelinux: move the stack to avoid AMI BIOS bug

syslinux-bot for H. Peter Anvin hpa at zytor.com
Fri Feb 12 16:51:11 PST 2010


Commit-ID:  831f1a04fbbbb1f65d95858b1b435325f67981f2
Gitweb:     http://syslinux.zytor.com/commit/831f1a04fbbbb1f65d95858b1b435325f67981f2
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Fri, 12 Feb 2010 13:37:20 -0800
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Fri, 12 Feb 2010 16:13:31 -0800

pxelinux: move the stack to avoid AMI BIOS bug

There is apparently some AMI BIOSes which leave a BEV stack just below
7c00h, which means that they can't return from the PXE NBP.  Thus, for
PXELINUX, move the stack down a few kilobytes.

This particularly refers to the "rouilj/ops12" system my private
sysdump archive.

Reported-and-tested-by: John Rouillard <rouilj at renesys.com>
Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 core/layout.inc   |   10 ++++++++++
 core/pxelinux.asm |   19 ++++++++++++++-----
 core/syslinux.ld  |    3 ---
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/core/layout.inc b/core/layout.inc
index 8c2e248..db035b5 100644
--- a/core/layout.inc
+++ b/core/layout.inc
@@ -26,6 +26,16 @@ BSS_START	equ 0800h
 ; Text starts at the load address of 07C00h.
 TEXT_START	equ 7C00h
 
+; Stack layout
+		global STACK_LEN, STACK_TOP, STACK_BASE
+STACK_LEN	equ 4096
+%if IS_PXELINUX
+STACK_TOP	equ 7000h
+%else
+STACK_TOP	equ 7c00h
+%endif
+STACK_BASE	equ STACK_TOP - STACK_LEN
+
 ; The secondary BSS section, above the text; we really wish we could
 ; just make it follow .bcopy32 or hang off the end,
 ; but it doesn't seem to work that way.
diff --git a/core/pxelinux.asm b/core/pxelinux.asm
index 6ad1584..c3caacd 100644
--- a/core/pxelinux.asm
+++ b/core/pxelinux.asm
@@ -212,12 +212,15 @@ pxe_unload_stack_pkt_len	equ $-pxe_unload_stack_pkt
 packet_buf	resb 2048		; Transfer packet
 packet_buf_size	equ $-packet_buf
 
+;
+; Location of the stack.  There are apparently some AMI BIOSes in the
+; field which put their BEV stack somewhere below 7C00h (and therefore
+; don't handle localboot properly), so avoid that immediate memory
+; region.
+;
+StackBuf	equ STACK_TOP-44	; Base of stack if we use our own
+
 		section .text
-		;
-		; PXELINUX needs more BSS than the other derivatives;
-		; therefore we relocate it from 7C00h on startup.
-		;
-StackBuf	equ $-44		; Base of stack if we use our own
 
 ;
 ; Primary entry point.
@@ -255,6 +258,12 @@ _start1:
 		mov ds,ax
 		mov es,ax
 
+		; Clobber the stack segment, to test for specific pathologies
+		mov di,STACK_BASE
+		mov cx,STACK_LEN >> 1
+		mov ax,0xf4f4
+		rep stosw
+
 		; That is all pushed onto the PXE stack.  Save the pointer
 		; to it and switch to an internal stack.
 		mov [InitStack],sp
diff --git a/core/syslinux.ld b/core/syslinux.ld
index c1da230..f6446e1 100644
--- a/core/syslinux.ld
+++ b/core/syslinux.ld
@@ -20,8 +20,6 @@ OUTPUT_ARCH(i386)
 EXTERN(_start)
 ENTRY(_start)
 
-STACK_LEN = 4096;
-
 SECTIONS
 {
 	/* "Early" sections (before the load) */
@@ -63,7 +61,6 @@ SECTIONS
 
 	/* Stack */
 
-	STACK_BASE = 0x7c00 - STACK_LEN;
 	. = STACK_BASE;
 	.stack : AT(STACK_BASE) {
 		__stack_start = .;



More information about the Syslinux-commits mailing list