Package: grub
Version: 0.97-28
Severity: important
Tags: patch

https://bugs.launchpad.net/bugs/106887

This problem was reported by "Linoleum" and "mpwalter" in Ubuntu bug #106887, 
but we tested the Debian packages 
as well, and they also need the patch. This was confirmed by "cs224" who runs 
Debian lenny. The patch was 
introduced in Mandriva and is also used by Red Hat.

>From the Ubuntu changelog (grub 0.97-20ubuntu7):

    Add patch from Mandriva grub-0.95-mem_lower.patch (Ubuntu bug #106887)
    Allows grub to boot on some computer where only lilo and syslinux
    would work. Uses memory detection similar to syslinux.
    http://www.mail-archive.com/[EMAIL PROTECTED]/msg06526.html


-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.21-1-486
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages grub depends on:
ii  libc6                         2.5-10     GNU C Library: Shared libraries
ii  libncurses5                   5.6-3      Shared libraries for terminal hand

grub recommends no packages.

-- no debconf information
diff -Naur grub-0.95.orig/stage2/common.c grub-0.95/stage2/common.c
--- grub-0.95.orig/stage2/common.c	2004-03-27 13:25:44.000000000 -0300
+++ grub-0.95/stage2/common.c	2004-12-08 17:36:36.590781312 -0200
@@ -108,26 +108,43 @@
   unsigned long long top;
   unsigned long addr;
   int cont;
-  
+
   top = bottom;
-  do
-    {
-      for (cont = 0, addr = mbi.mmap_addr;
-	   addr < mbi.mmap_addr + mbi.mmap_length;
-	   addr += *((unsigned long *) addr) + 4)
+    /* If detecting mbi.mem_lower */
+    if (bottom == 0) {
+	/* Initialize to 640Kb */
+	top = 0xA0000ULL;
+	for (addr = mbi.mmap_addr;
+	     addr < mbi.mmap_addr + mbi.mmap_length;
+	     addr += *((unsigned long *) addr) + 4) {
+	    struct AddrRangeDesc *desc = (struct AddrRangeDesc *) addr;
+
+	    /* If there is anything reserved below 640Kb */
+	    if (desc->BaseAddr < top && desc->Length &&
+		desc->Type != MB_ARD_MEMORY)
+		top = desc->BaseAddr;
+	}
+    }
+    else {
+      do
 	{
-	  struct AddrRangeDesc *desc = (struct AddrRangeDesc *) addr;
-	  
-	  if (desc->Type == MB_ARD_MEMORY
-	      && desc->BaseAddr <= top
-	      && desc->BaseAddr + desc->Length > top)
+	  for (cont = 0, addr = mbi.mmap_addr;
+	       addr < mbi.mmap_addr + mbi.mmap_length;
+	       addr += *((unsigned long *) addr) + 4)
 	    {
-	      top = desc->BaseAddr + desc->Length;
-	      cont++;
+	      struct AddrRangeDesc *desc = (struct AddrRangeDesc *) addr;
+	  
+	      if (desc->Type == MB_ARD_MEMORY
+		  && desc->BaseAddr <= top
+		  && desc->BaseAddr + desc->Length > top)
+		{
+		  top = desc->BaseAddr + desc->Length;
+		  cont++;
+		}
 	    }
 	}
+      while (cont);
     }
-  while (cont);
 
   /* For now, GRUB assumes 32bits addresses, so...  */
   if (top > 0xFFFFFFFF)
@@ -194,6 +211,7 @@
   if (mbi.mmap_length)
     {
       unsigned long long max_addr;
+      unsigned long mem_lower = mmap_avail_at (0) >> 10;
       
       /*
        *  This is to get the lower memory, and upper memory (up to the
@@ -201,7 +219,8 @@
        *  elements.  This is for OS's that don't care about the memory
        *  map, but might care about total RAM available.
        */
-      mbi.mem_lower = mmap_avail_at (0) >> 10;
+      if (mem_lower < mbi.mem_lower)
+	mbi.mem_lower = mem_lower;
       mbi.mem_upper = mmap_avail_at (0x100000) >> 10;
 
       /* Find the maximum available address. Ignore any memory holes.  */

Reply via email to