From: H. Peter Anvin Date: Thu, 17 Aug 2006 21:24:43 +0000 (-0700) Subject: When exiting a COMBOOT/COM32 module, reset the stack instead of saving X-Git-Tag: syslinux-3.20-pre12~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5f7ba5958af6985fdb7b1f1d86c92691786544a1;p=profile%2Fivi%2Fsyslinux.git When exiting a COMBOOT/COM32 module, reset the stack instead of saving and restoring it. The former option left crap on the stack. --- diff --git a/abort.inc b/abort.inc index 78347d5..5b87c68 100644 --- a/abort.inc +++ b/abort.inc @@ -1,7 +1,6 @@ -; $Id$ ; ----------------------------------------------------------------------- ; -; Copyright 2005 H. Peter Anvin - All Rights Reserved +; Copyright 2005-2006 H. Peter Anvin - All Rights Reserved ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by @@ -50,16 +49,7 @@ abort_load: mov ax,cs ; Restore CS = DS = ES mov ds,ax mov es,ax -%if IS_SYSLINUX || IS_EXTLINUX - mov ss,ax ; Just in case... - mov sp,StackBuf-2*3 ; Reset stack -%elif IS_PXELINUX - lss esp,[BaseStack] -%elif IS_ISOLINUX - lss sp,[StackPtr] -%else - NEED TO KNOW HOW TO RESET STACK -%endif + RESET_STACK sti call cwritestr ; Expects SI -> error msg diff --git a/bcopy32.inc b/bcopy32.inc index 652c4b3..237eb81 100644 --- a/bcopy32.inc +++ b/bcopy32.inc @@ -453,6 +453,5 @@ __bcopy_size equ $-__bcopy_start section .earlybss alignb 2 EntryPoint resd 1 ; CS:IP for shuffle_and_boot -SavedSSSP resd 1 ; Saved real mode SS:SP A20Test resw 1 ; Counter for testing status of A20 A20Tries resb 1 ; Times until giving up on A20 diff --git a/com32.inc b/com32.inc index e607537..07d0c1c 100644 --- a/com32.inc +++ b/com32.inc @@ -75,8 +75,8 @@ com32_enter_pm: cli mov ax,cs mov ds,ax - mov [SavedSSSP],sp - mov [SavedSSSP+2],ss + mov [RealModeSSSP],sp + mov [RealModeSSSP+2],ss cld call a20_test jnz .a20ok @@ -200,7 +200,7 @@ com32_enter_rm: mov es,ax mov fs,ax mov gs,ax - lss sp,[SavedSSSP] ; Restore stack + lss sp,[RealModeSSSP] ; Restore stack jmp bx ; Go to whereever we need to go... com32_done: @@ -303,10 +303,10 @@ com32_intcall: com32_syscall: cld - movzx edi,word [word SavedSSSP] - movzx ebx,word [word SavedSSSP+2] + movzx edi,word [word RealModeSSSP] + movzx ebx,word [word RealModeSSSP+2] sub edi,54 ; Allocate 54 bytes - mov [word SavedSSSP],di + mov [word RealModeSSSP],di shl ebx,4 add edi,ebx ; Create linear address @@ -331,8 +331,8 @@ com32_syscall: ; real-mode stack, plus the 10 additional bytes used ; by the target address (see above.) com32_sys_resume: - movzx esi,word [word SavedSSSP] - movzx eax,word [word SavedSSSP+2] + movzx esi,word [word RealModeSSSP] + movzx eax,word [word RealModeSSSP+2] mov edi,[esp+12*4] ; Dest regs shl eax,4 add esi,eax ; Create linear address @@ -343,7 +343,7 @@ com32_sys_resume: mov cl,11 ; 44 bytes rep movsd ; Copy register block - add dword [word SavedSSSP],54 ; Remove from stack + add dword [word RealModeSSSP],54 ; Remove from stack popad popfd @@ -353,6 +353,7 @@ com32_sys_resume: section .bss alignb 4 +RealModeSSSP resd 1 ; Real-mode SS:SP PMESP resd 1 ; Protected-mode ESP Com32SysSP resw 1 ; SP saved during COM32 syscall diff --git a/comboot.inc b/comboot.inc index eaeab5c..91a7da9 100644 --- a/comboot.inc +++ b/comboot.inc @@ -132,9 +132,6 @@ is_comboot_image: call getfssec ; And invoke the program... - mov [SavedSSSP],sp - mov [SavedSSSP+2],ss ; Save away SS:SP - mov ax,es mov ds,ax mov ss,ax @@ -213,7 +210,7 @@ comboot_exit_special: xor dx,dx mov ds,dx mov es,dx - lss sp,[SavedSSSP] + RESET_STACK sti cld call adjust_screen ; The COMBOOT program might have changed the screen diff --git a/extlinux.asm b/extlinux.asm index 0b93e0a..123c4f6 100644 --- a/extlinux.asm +++ b/extlinux.asm @@ -1,12 +1,11 @@ ; -*- fundamental -*- (asm-mode sucks) -; $Id$ ; **************************************************************************** ; ; extlinux.asm ; ; A program to boot Linux kernels off an ext2/ext3 filesystem. ; -; Copyright (C) 1994-2005 H. Peter Anvin +; Copyright (C) 1994-2006 H. Peter Anvin ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by @@ -17,13 +16,7 @@ ; **************************************************************************** %define IS_EXTLINUX 1 -%include "macros.inc" -%include "config.inc" -%include "kernel.inc" -%include "bios.inc" -%include "tracers.inc" -%include "layout.inc" - +%include "head.inc" %include "ext2_fs.inc" ; diff --git a/isolinux.asm b/isolinux.asm index 113fba1..4d2a472 100644 --- a/isolinux.asm +++ b/isolinux.asm @@ -1,5 +1,4 @@ ; -*- fundamental -*- (asm-mode sucks) -; $Id$ ; **************************************************************************** ; ; isolinux.asm @@ -9,7 +8,7 @@ ; available. It is based on the SYSLINUX boot loader for MS-DOS ; floppies. ; -; Copyright (C) 1994-2005 H. Peter Anvin +; Copyright (C) 1994-2006 H. Peter Anvin ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by @@ -20,12 +19,7 @@ ; **************************************************************************** %define IS_ISOLINUX 1 -%include "macros.inc" -%include "config.inc" -%include "kernel.inc" -%include "bios.inc" -%include "tracers.inc" -%include "layout.inc" +%include "head.inc" ; ; Some semi-configurable constants... change on your own risk. diff --git a/ldlinux.asm b/ldlinux.asm index 0f5c0cd..dfb2397 100644 --- a/ldlinux.asm +++ b/ldlinux.asm @@ -25,12 +25,8 @@ %ifndef IS_MDSLINUX %define IS_SYSLINUX 1 %endif -%include "macros.inc" -%include "config.inc" -%include "kernel.inc" -%include "bios.inc" -%include "tracers.inc" -%include "layout.inc" +%include "head.inc" + ; ; Some semi-configurable constants... change on your own risk. ; diff --git a/pxelinux.asm b/pxelinux.asm index 90e7a5c..5809a47 100644 --- a/pxelinux.asm +++ b/pxelinux.asm @@ -1,5 +1,4 @@ ; -*- fundamental -*- (asm-mode sucks) -; $Id$ ; **************************************************************************** ; ; pxelinux.asm @@ -8,7 +7,7 @@ ; network booting API. It is based on the SYSLINUX boot loader for ; MS-DOS floppies. ; -; Copyright (C) 1994-2005 H. Peter Anvin +; Copyright (C) 1994-2006 H. Peter Anvin ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by @@ -19,13 +18,8 @@ ; **************************************************************************** %define IS_PXELINUX 1 -%include "macros.inc" -%include "config.inc" -%include "kernel.inc" -%include "bios.inc" -%include "tracers.inc" +%include "head.inc" %include "pxe.inc" -%include "layout.inc" ; ; Some semi-configurable constants... change on your own risk. @@ -1897,48 +1891,6 @@ unload_pxe: jmp .call_loop .call_done: -; -; This isn't necessary anymore; we can use the memory area previously -; used by the PXE stack indefinitely, and the chainload code sets up -; a new stack independently. Leave the source code in here for now, -; but expect to rip it out soonish. -; -%if 0 ; USE_PXE_PROVIDED_STACK - ; We need to switch to our local stack here... - pusha - pushf - push gs - - mov si,sp - mov ax,ss - mov gs,ax - sub ax,[BaseStack+4] ; Are we using the base stack - je .is_base_stack ; (as opposed to the COMBOOT stack)? - - lgs si,[SavedSSSP] ; COMBOOT stack -.is_base_stack: - - mov cx,[InitStack] - mov di,StackBuf - mov [BaseStack],di - mov [BaseStack+4],es - sub cx,si - sub di,cx - mov [SavedSSSP],di ; New SP - mov [SavedSSSP+2],es - gs rep movsb - - and ax,ax ; Remember which stack - jne .combootstack - - ; Update the base stack pointer since it's in use - lss sp,[SavedSSSP] - -.combootstack: - pop gs - popf - popa -%endif mov bx,0FF00h mov dx,[RealBaseMem] diff --git a/stack.inc b/stack.inc new file mode 100644 index 0000000..c3297ed --- /dev/null +++ b/stack.inc @@ -0,0 +1,38 @@ +; ----------------------------------------------------------------------- +; +; Copyright 2005-2006 H. Peter Anvin - All Rights Reserved +; +; This program is free software; you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation, Inc., 53 Temple Place Ste 330, +; Boston MA 02111-1307, USA; either version 2 of the License, or +; (at your option) any later version; incorporated herein by reference. +; +; ----------------------------------------------------------------------- + +; +; stack.inc +; +; How to reset the stack pointer +; + +%ifndef _STACK_INC +%define _STACK_INC + +; +; This macro resets the stack pointer. It assumes CS == DS. +; +%macro RESET_STACK 0 +%if IS_SYSLINUX || IS_EXTLINUX + mov ss,ax ; Just in case... + mov sp,StackBuf-2*3 ; Reset stack +%elif IS_PXELINUX + lss esp,[BaseStack] +%elif IS_ISOLINUX + lss sp,[StackPtr] +%else + NEED TO KNOW HOW TO RESET STACK +%endif +%endmacro + +%endif ; _STACK_INC