e820 memory detection (was Re: 2.4.0-test3 oops (BIOS bug))

From: Marc Zyngier (mzyngier@freesurf.fr)
Date: Thu Jul 20 2000 - 01:54:49 EST


>>>>> "Jean" == Jean Tourrilhes <jt@bougret.hpl.hp.com> writes:

Jean> I spent enough hours trying to fight this bug, which is quite
Jean> difficult to pin point, and I don't want other people to waste as much
Jean> time as I did, especially if it is a known problem but not documented.

Yes, I spent almost 2 months trying random 2.3 versions, and only
found this while suspecting bad memory, and booting the machine with
8MB, which resulted in an instant crash, while it would only crash
under heavy load with 96MB...

Jean> So, I guess what I'm saying is that a fix for this problem
Jean> would be more than welcomed in the standard kernel. Maybe there should
Jean> be a BIOS blacklist ;-)

Here's the patch I sent to LKML back in december. I've been told by
Nathan Zook to forget about this, since there was a better (and much
more complete) memory detection patch under way. Alas, such patch
hasn't made it into the kernel yet, and a whole range of systems is
currently left in the dust for 2.4, at least without adding the
mem=xxx option, which was not exactly easy to guess...

--- linux/arch/i386/kernel/setup.c.orig Mon Dec 13 19:22:03 1999
+++ linux/arch/i386/kernel/setup.c Mon Dec 13 19:22:22 1999
@@ -406,9 +406,7 @@
 void __init setup_memory_region(void)
 {
 #define E820_DEBUG 1
-#ifdef E820_DEBUG
         int i;
-#endif
 
         /*
          * If we're lucky and live on a modern system, the setup code
@@ -421,6 +419,9 @@
          * regions: one from 0 to 640k, and one from 1mb up. (The IBM
          * thinkpad 560x, for example, does not cooperate with the memory
          * detection code.)
+ *
+ * Do not trust e820 maps telling you that there is usable RAM
+ * sitting between 640k and 1MB, this is probably a lie...
          */
         if (E820_MAP_NR > 1) {
                 /* got a memory map; copy it into a safe place.
@@ -429,13 +430,23 @@
                 if (e820.nr_map > E820MAX)
                         e820.nr_map = E820MAX;
                 memcpy(e820.map, E820_MAP, e820.nr_map * sizeof e820.map[0]);
-#ifdef E820_DEBUG
                 for (i=0; i < e820.nr_map; i++) {
+#ifdef E820_DEBUG
                         printk("e820: %08x @ %08x ", (int)e820.map[i].size,
                                                 (int)e820.map[i].addr);
+#endif
                         switch (e820.map[i].type) {
- case E820_RAM: printk("(usable)\n");
+ case E820_RAM: if ((int) e820.map[i].addr >= LOWMEMSIZE() &&
+ (int) e820.map[i].addr < HIGH_MEMORY) {
+ e820.map[i].type = E820_RESERVED;
+#ifdef E820_DEBUG
+ printk ("(was usable, forced to reserved)\n");
+ } else {
+ printk("(usable)\n");
+#endif
+ }
                                         break;
+#ifdef E820_DEBUG
                         case E820_RESERVED:
                                         printk("(reserved)\n");
                                         break;
@@ -447,9 +458,9 @@
                                         break;
                         default: printk("type %lu\n", e820.map[i].type);
                                         break;
+#endif
                         }
                 }
-#endif
         }
         else {
                 /* otherwise fake a memory map; one section from 0k->640k,

Jean> Merci encore pour le tuyeau...

De rien...

        M.

-- 
Places change, faces change. Life is so very strange.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Jul 23 2000 - 21:00:13 EST