]> nv-tegra.nvidia Code Review - linux-2.6.git/commitdiff
[PATCH] x86-64: Handle empty E820 regions correctly
authorVenkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Sun, 1 May 2005 15:58:52 +0000 (08:58 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sun, 1 May 2005 15:58:52 +0000 (08:58 -0700)
Brings sanitize_e820_map() in x86-64 in sync with that of i386.

x86_64 version was missing the changes from this patch.
http://linux.bkbits.net:8080/linux-2.6/cset@3e5e4083Y3HevldZl5KCy94V4DcZww?nav=index.html|src/|src/arch|src/arch/i386|src/arch/i386/kernel|related/arch/i386/kernel/setup.c

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Acked-by: Andi Kleen <ak@muc.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/x86_64/kernel/e820.c

index 56516ac92e5d4b514d59aec823ea9767729180bf..7c154dfff64aa406b15294236eee46a738837ee8 100644 (file)
@@ -2,6 +2,12 @@
  * Handle the memory map.
  * The functions here do the job until bootmem takes over.
  * $Id: e820.c,v 1.4 2002/09/19 19:25:32 ak Exp $
+ *
+ *  Getting sanitize_e820_map() in sync with i386 version by applying change:
+ *  -  Provisions for empty E820 memory regions (reported by certain BIOSes).
+ *     Alex Achenbach <xela@slit.de>, December 2002.
+ *  Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
+ *
  */
 #include <linux/config.h>
 #include <linux/kernel.h>
@@ -277,7 +283,7 @@ static int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
        int chgidx, still_changing;
        int overlap_entries;
        int new_bios_entry;
-       int old_nr, new_nr;
+       int old_nr, new_nr, chg_nr;
        int i;
 
        /*
@@ -331,20 +337,24 @@ static int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
        for (i=0; i < 2*old_nr; i++)
                change_point[i] = &change_point_list[i];
 
-       /* record all known change-points (starting and ending addresses) */
+       /* record all known change-points (starting and ending addresses),
+          omitting those that are for empty memory regions */
        chgidx = 0;
        for (i=0; i < old_nr; i++)      {
-               change_point[chgidx]->addr = biosmap[i].addr;
-               change_point[chgidx++]->pbios = &biosmap[i];
-               change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
-               change_point[chgidx++]->pbios = &biosmap[i];
+               if (biosmap[i].size != 0) {
+                       change_point[chgidx]->addr = biosmap[i].addr;
+                       change_point[chgidx++]->pbios = &biosmap[i];
+                       change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
+                       change_point[chgidx++]->pbios = &biosmap[i];
+               }
        }
+       chg_nr = chgidx;
 
        /* sort change-point list by memory addresses (low -> high) */
        still_changing = 1;
        while (still_changing)  {
                still_changing = 0;
-               for (i=1; i < 2*old_nr; i++)  {
+               for (i=1; i < chg_nr; i++)  {
                        /* if <current_addr> > <last_addr>, swap */
                        /* or, if current=<start_addr> & last=<end_addr>, swap */
                        if ((change_point[i]->addr < change_point[i-1]->addr) ||
@@ -367,7 +377,7 @@ static int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
        last_type = 0;           /* start with undefined memory type */
        last_addr = 0;           /* start with 0 as last starting address */
        /* loop through change-points, determining affect on the new bios map */
-       for (chgidx=0; chgidx < 2*old_nr; chgidx++)
+       for (chgidx=0; chgidx < chg_nr; chgidx++)
        {
                /* keep track of all overlapping bios entries */
                if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr)