From: "H. Peter Anvin" <hpa@zytor.com>
To: Joseph Parmelee <jparmele@wildbear.com>
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org
Subject: Re: Old version of lilo fails to boot 2.6.23
Date: Thu, 25 Oct 2007 15:31:43 -0700 [thread overview]
Message-ID: <4721194F.1040202@zytor.com> (raw)
In-Reply-To: <47211070.4090502@zytor.com>
[-- Attachment #1: Type: text/plain, Size: 168 bytes --]
H. Peter Anvin wrote:
> [Ancient LILO boot problem]
>
> Joseph, could you try this patch on your ancient-LILO setup?
>
Actually, please try this one instead.
-hpa
[-- Attachment #2: newsetup-ancient-lilo-2.patch --]
[-- Type: text/x-patch, Size: 2504 bytes --]
diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
index 5f9a2e7..887874f 100644
--- a/arch/x86/boot/boot.h
+++ b/arch/x86/boot/boot.h
@@ -17,6 +17,8 @@
#ifndef BOOT_BOOT_H
#define BOOT_BOOT_H
+#define STACK_SIZE 512 /* Minimum number of bytes for stack */
+
#ifndef __ASSEMBLY__
#include <stdarg.h>
@@ -198,8 +200,6 @@ static inline int isdigit(int ch)
}
/* Heap -- available for dynamic lists. */
-#define STACK_SIZE 512 /* Minimum number of bytes for stack */
-
extern char _end[];
extern char *HEAP;
extern char *heap_end;
diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index 8353c81..256098d 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -173,7 +173,7 @@ ramdisk_size: .long 0 # its size in bytes
bootsect_kludge:
.long 0 # obsolete
-heap_end_ptr: .word _end+1024 # (Header version 0x0201 or later)
+heap_end_ptr: .word _end+STACK_SIZE # (Header version 0x0201 or later)
# space from here (exclusive) down to
# end of setup code can be used by setup
# for local heap purposes.
@@ -242,16 +242,38 @@ setup2:
movw %ax, %es
cld
-# Stack paranoia: align the stack and make sure it is good
-# for both 16- and 32-bit references. In particular, if we
-# were meant to have been using the full 16-bit segment, the
-# caller might have set %sp to zero, which breaks %esp-based
-# references.
- andw $~3, %sp # dword align (might as well...)
+# Apparently some ancient versions of LILO invoked the kernel
+# with %ss != %ds, which happened to work by accident for the
+# old code. If the CAN_USE_HEAP flag is set in loadflags, or
+# %ss != %ds, then adjust the stack pointer.
+
+ # Smallest possible stack we can tolerate
+ movw $(_end+STACK_SIZE), %cx
+
+ testb $CAN_USE_HEAP, loadflags
+ jnz 2f
+
+ # No CAN_USE_HEAP
+ movw %ss, %dx
+ cmpw %ax, %dx # %ds == %ss?
+ movw %sp, %dx
+ je 3f # If so, assume %sp is valid
+
+2:
+ movw heap_end_ptr, %dx
+
+ # Make sure the stack is at least minimum size. Take a value
+ # of zero to mean "full segment."
+3:
+ andw $~3, %dx # dword align (might as well...)
jnz 1f
- movw $0xfffc, %sp # Make sure we're not zero
-1: movzwl %sp, %esp # Clear upper half of %esp
- sti
+ movw $0xfffc, %dx # Make sure we're not zero
+1: cmpw %cx, %dx
+ jnb 4f
+ movw %cx, %dx # Minimum value we can possibly use
+4: movw %ax, %ss
+ movzwl %dx, %esp # Clear upper half of %esp
+ sti # Now we should have a working stack
# Check signature at end of setup
cmpl $0x5a5aaa55, setup_sig
next prev parent reply other threads:[~2007-10-25 22:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-16 7:07 Old version of lilo fails to boot 2.6.23 Joseph Parmelee
2007-10-25 8:47 ` Andrew Morton
2007-10-25 9:08 ` H. Peter Anvin
2007-10-25 21:53 ` H. Peter Anvin
2007-10-25 22:31 ` H. Peter Anvin [this message]
2007-10-26 18:25 ` Joseph Parmelee
2007-10-26 18:37 ` H. Peter Anvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4721194F.1040202@zytor.com \
--to=hpa@zytor.com \
--cc=akpm@linux-foundation.org \
--cc=jparmele@wildbear.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox