Re: Old version of lilo fails to boot 2.6.23

H. Peter Anvin
2007-10-25T21:54:18Z

[-- Attachment #1: Type: text/plain, Size: 97 bytes --]

[Ancient LILO boot problem]

Joseph, could you try this patch on your ancient-LILO setup?

-hpa

[-- Attachment #2: newsetup-ancient-lilo.patch --]
[-- Type: text/x-patch, Size: 1140 bytes --]

diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index 8353c81..295f9b9 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -242,11 +242,31 @@ setup2:
movw %ax, %es
cld

+# 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.
+ testb $CAN_USE_HEAP, loadflags
+ jnz 2f
+
+ # No CAN_USE_HEAP
+ movw %ss, %dx
+ cmpw %ax, %dx # %ds == %ss?
+ je 3f # If so, assume %sp is valid
+
+ # If not, use the default value from heap_end_ptr
+ # as the %sp value -- it's the best we can do with an
+ # impossible situation.
+2:
+ movw %ax, %ss
+ movw heap_end_ptr, %sp
+
# 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.
+3:
andw $~3, %sp # dword align (might as well...)
jnz 1f
movw $0xfffc, %sp # Make sure we're not zero