提交 f014a556 编写于 作者: D Dave Hansen 提交者: Linus Torvalds

[PATCH] fixup bogus e820 entry with mem=

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.
Signed-off-by: NDave Hansen <haveblue@us.ibm.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 750deaa4
...@@ -389,14 +389,24 @@ static void __init limit_regions(unsigned long long size) ...@@ -389,14 +389,24 @@ static void __init limit_regions(unsigned long long size)
} }
} }
for (i = 0; i < e820.nr_map; i++) { 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;
current_addr = e820.map[i].addr + e820.map[i].size; if (current_addr < size)
if (current_addr >= size) { continue;
e820.map[i].size -= current_addr-size;
e820.nr_map = i + 1; if (e820.map[i].type != E820_RAM)
return; 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;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册