public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <haveblue@us.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	John Stultz <jstultz@alumni.cmu.edu>,
	Dale Mosby <k7fw@us.ibm.com>
Subject: [PATCH] fixup bogus e820 entry with mem=
Date: Mon, 26 Sep 2005 08:40:01 -0700	[thread overview]
Message-ID: <1127749201.26894.4.camel@localhost> (raw)

This was reported because someone was getting oopses
reading /proc/iomem.  It was tracked down to a zero-sized 'struct
resource' entry which was located right at 4GB.  

You need two conditions to hit this bug: a BIOS E820_RAM area starting
at exactly the boundary where you specify mem= (to get a zero-sized
entry), and for the legacy_init_iomem_resources() loop to skip  that
resource (which only happens at exactly 4G).

I think the killing zero-sized e820 entry is the easiest way to fix
this.  

-- Dave

Signed-off-by: Dave Hansen <haveblue@us.ibm.com>

 linux/arch/i386/kernel/setup.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff -puN arch/i386/kernel/setup.c~e820-empty arch/i386/kernel/setup.c
--- linux.orig/arch/i386/kernel/setup.c~e820-empty	2005-09-13 16:08:40.000000000 -0700
+++ linux/arch/i386/kernel/setup.c	2005-09-13 16:14:20.000000000 -0700
@@ -388,14 +388,24 @@ static void __init limit_regions(unsigne
 		}
 	}
 	for (i = 0; i < e820.nr_map; i++) {
-		if (e820.map[i].type == E820_RAM) {
-			current_addr = e820.map[i].addr + e820.map[i].size;
-			if (current_addr >= size) {
-				e820.map[i].size -= current_addr-size;
-				e820.nr_map = i + 1;
-				return;
-			}
+		current_addr = e820.map[i].addr + e820.map[i].size;
+		if (current_addr < size)
+			continue;
+
+		if (e820.map[i].type != E820_RAM)
+			continue;
+
+		if (e820.map[i].addr >= size) {
+			/*
+			 * This region starts past the end of the
+			 * requested size, skip it completely.
+			 */
+			e820.nr_map = i;
+		} else {
+			e820.nr_map = i + 1;
+			e820.map[i].size -= current_addr - size;
 		}
+		return;
 	}
 }
 
_



                 reply	other threads:[~2005-09-26 15:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1127749201.26894.4.camel@localhost \
    --to=haveblue@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=jstultz@alumni.cmu.edu \
    --cc=k7fw@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox