[x86 setup] Unbreak booting with Loadlin and old LILO

Previous thread: [PATCH] pidns: Place under CONFIG_EXPERIMENTAL (take 2) by Eric W. Biederman on Friday, October 26, 2007 - 12:35 pm. (3 messages)

Next thread: [PATCH] audit: clear thread flag for new children by Tony Jones on Friday, October 26, 2007 - 1:42 pm. (9 messages)
From: H. Peter Anvin
Date: Friday, October 26, 2007 - 1:02 pm

Hi Linus,

Please pull:

  git://git.kernel.org/pub/scm/linux/kernel/git/hpa/linux-2.6-x86setup.git for-linus

These patches unbreaks booting with some old versions of LILO and
Loadlin.

These patches probably should be considered for -stable as well (with
s/x86/i386/ in the pathnames.)

H. Peter Anvin (2):
      x86 setup: handle boot loaders which set up the stack incorrectly
      x86 setup: sizeof() is unsigned, unbreak comparisons

 arch/x86/boot/boot.h       |    8 +++---
 arch/x86/boot/header.S     |   62 +++++++++++++++++++++++++++++++------------
 arch/x86/boot/video-bios.c |    2 +-
 arch/x86/boot/video-vesa.c |    2 +-
 arch/x86/boot/video.c      |    2 +-
 5 files changed, 51 insertions(+), 25 deletions(-)

[Full diffs and log messages follow]

commit e6e1ace9904b72478f0c5a5aa7bd174cb6f62561
Author: H. Peter Anvin <hpa@zytor.com>
Date:   Thu Oct 25 16:09:38 2007 -0700

    x86 setup: sizeof() is unsigned, unbreak comparisons
    
    We use signed values for limit checking since the values can go
    negative under certain circumstances.  However, sizeof() is unsigned
    and forces the comparison to be unsigned, so move the comparison into
    the heap_free() macros so we can ensure it is a signed comparison.
    
    Signed-off-by: H. Peter Anvin <hpa@zytor.com>

diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
index 887874f..d2b5adf 100644
--- a/arch/x86/boot/boot.h
+++ b/arch/x86/boot/boot.h
@@ -216,9 +216,9 @@ static inline char *__get_heap(size_t s, size_t a, size_t n)
 #define GET_HEAP(type, n) \
 	((type *)__get_heap(sizeof(type),__alignof__(type),(n)))
 
-static inline int heap_free(void)
+static inline bool heap_free(size_t n)
 {
-	return heap_end-HEAP;
+	return (int)(heap_end-HEAP) >= (int)n;
 }
 
 /* copy.S */
diff --git a/arch/x86/boot/video-bios.c b/arch/x86/boot/video-bios.c
index 68e65d9..ed0672a 100644
--- a/arch/x86/boot/video-bios.c
+++ b/arch/x86/boot/video-bios.c
@@ -79,7 +79,7 @@ static int bios_probe(void)
 ...
Previous thread: [PATCH] pidns: Place under CONFIG_EXPERIMENTAL (take 2) by Eric W. Biederman on Friday, October 26, 2007 - 12:35 pm. (3 messages)

Next thread: [PATCH] audit: clear thread flag for new children by Tony Jones on Friday, October 26, 2007 - 1:42 pm. (9 messages)