From: Mel Gorman <mel@csn.ul.ie>
To: Ingo Molnar <mingo@elte.hu>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Pekka Enberg <penberg@cs.helsinki.fi>,
Christoph Lameter <clameter@sgi.com>,
linux-kernel@vger.kernel.org, Nick Piggin <npiggin@suse.de>,
Andrew Morton <akpm@linux-foundation.org>,
"Rafael J. Wysocki" <rjw@sisk.pl>,
Yinghai.Lu@sun.com, apw@shadowen.org,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Subject: Re: [patch] mm: sparsemem memory_present() memory corruption fix
Date: Wed, 16 Apr 2008 15:05:13 +0100 [thread overview]
Message-ID: <20080416140512.GA1438@csn.ul.ie> (raw)
In-Reply-To: <20080416000356.GA24737@elte.hu>
On (16/04/08 02:03), Ingo Molnar didst pronounce:
>
> finally found it ... the patch below solves the sparsemem crash and the
> testsystem boots up fine now:
>
> mars:~> uname -a
> Linux mars 2.6.25-rc9-sched-devel.git-x86-latest.git #985 SMP Wed Apr 16
> 01:37:37 CEST 2008 i686 i686 i386 GNU/Linux
>
> yay! :-)
>
Very cool :) This fixed the silent lock-up that I was getting when using
your config as well.
At a bit of a loss yesterday to explain what was going wrong, I had started
putting together patches to sanity check memory initialisation at various
different stages trying to catch where things were going pear-shaped. You
found the bug before it was done but I finished the basics anyway and posted
it as "[RFC] Verification and debugging of memory initialisation". Something
like it may help avoid similar headaches for people who tend to run into
(or cause) boot problems.
> ps. anyone who can correctly guess the method with which i found the
> exact place that corrupted memory will get a free beer next time we
> meet :-)
>
> ------------------------->
> Subject: mm: sparsemem memory_present() memory corruption fix
> From: Ingo Molnar <mingo@elte.hu>
> Date: Wed Apr 16 01:40:00 CEST 2008
>
> fix memory corruption and crash on 32-bit x86 systems.
>
> if a !PAE x86 kernel is booted on a 32-bit system with more than
> 4GB of RAM, then we call memory_present() with a start/end that
> goes outside the scope of MAX_PHYSMEM_BITS.
>
> that causes this loop to happily walk over the limit of the
> sparse memory section map:
>
> for (pfn = start; pfn < end; pfn += PAGES_PER_SECTION) {
> unsigned long section = pfn_to_section_nr(pfn);
> struct mem_section *ms;
>
> sparse_index_init(section, nid);
> set_section_nid(section, nid);
>
> ms = __nr_to_section(section);
> if (!ms->section_mem_map)
> ms->section_mem_map = sparse_encode_early_nid(nid) |
>
> 'ms' will be out of bounds and we'll corrupt a small amount of memory by
> encoding the node ID. Depending on what that memory is, we might crash,
> misbehave or just not notice the bug.
>
> the fix is to sanity check anything the architecture passes to sparsemem.
>
> this bug seems to be rather old (as old as sparsemem support itself),
> but the exact incarnation depended on random details like configs,
> which made this bug more prominent in v2.6.25-to-be.
>
> an additional enhancement might be to print a warning about ignored
> or trimmed memory ranges.
>
> Signed-off-by: Ingo Molnar <mingo@elte.hu>
> ---
> mm/sparse.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> Index: linux/mm/sparse.c
> ===================================================================
> --- linux.orig/mm/sparse.c
> +++ linux/mm/sparse.c
> @@ -149,8 +149,18 @@ static inline int sparse_early_nid(struc
> /* Record a memory area against a node. */
> void __init memory_present(int nid, unsigned long start, unsigned long end)
> {
> + unsigned long max_arch_pfn = 1ULL << (MAX_PHYSMEM_BITS-PAGE_SHIFT);
> unsigned long pfn;
>
> + /*
> + * Sanity checks - do not allow an architecture to pass
> + * in larger pfns than the maximum scope of sparsemem:
> + */
> + if (start >= max_arch_pfn)
> + return;
> + if (end >= max_arch_pfn)
> + end = max_arch_pfn;
> +
> start &= PAGE_SECTION_MASK;
> for (pfn = start; pfn < end; pfn += PAGES_PER_SECTION) {
> unsigned long section = pfn_to_section_nr(pfn);
>
--
Mel Gorman
Part-time Phd Student Linux Technology Center
University of Limerick IBM Dublin Software Lab
next prev parent reply other threads:[~2008-04-16 14:05 UTC|newest]
Thread overview: 95+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-11 7:41 [bug] mm/slab.c boot crash in -git, "kernel BUG at mm/slab.c:2103!" Ingo Molnar
2008-04-11 8:21 ` Pekka Enberg
2008-04-11 8:50 ` Pekka Enberg
2008-04-11 8:54 ` Ingo Molnar
2008-04-11 9:05 ` Pekka Enberg
2008-04-11 9:08 ` Pekka Enberg
2008-04-11 9:11 ` Pekka Enberg
2008-04-11 9:24 ` Ingo Molnar
2008-04-11 10:34 ` Nick Piggin
2008-04-11 19:28 ` Christoph Lameter
2008-04-12 10:38 ` Christoph Lameter
2008-04-12 17:22 ` Yinghai Lu
2008-04-15 5:43 ` Ingo Molnar
2008-04-15 9:36 ` Mel Gorman
2008-04-15 10:03 ` Ingo Molnar
2008-04-15 6:25 ` [bug] SLUB + mm/slab.c boot crash in -rc9 Ingo Molnar
2008-04-15 6:41 ` Pekka Enberg
2008-04-15 7:08 ` Ingo Molnar
2008-04-15 8:31 ` Yinghai Lu
2008-04-15 8:46 ` Ingo Molnar
2008-04-15 9:11 ` Ingo Molnar
2008-04-15 16:02 ` Linus Torvalds
2008-04-15 16:15 ` Ingo Molnar
2008-04-15 17:23 ` Linus Torvalds
2008-04-15 19:35 ` Ingo Molnar
2008-04-15 19:41 ` Ingo Molnar
2008-04-15 19:39 ` Christoph Lameter
2008-04-15 19:54 ` Ingo Molnar
2008-04-15 20:03 ` Christoph Lameter
2008-04-15 20:17 ` Ingo Molnar
2008-04-15 20:28 ` Ingo Molnar
2008-04-15 20:34 ` Ingo Molnar
2008-04-15 20:42 ` Ingo Molnar
2008-04-15 20:50 ` Christoph Lameter
2008-04-15 20:58 ` Ingo Molnar
2008-04-15 21:08 ` Christoph Lameter
2008-04-15 21:16 ` Mike Travis
2008-04-15 21:19 ` Ingo Molnar
2008-04-15 21:21 ` Christoph Lameter
2008-04-15 21:23 ` Ingo Molnar
2008-04-15 21:24 ` Christoph Lameter
2008-04-15 21:28 ` Ingo Molnar
2008-04-15 21:33 ` Christoph Lameter
2008-04-15 21:43 ` Mike Travis
2008-04-15 22:07 ` Ingo Molnar
2008-04-15 21:27 ` Mike Travis
2008-04-15 20:34 ` Pekka Enberg
2008-04-15 20:40 ` Ingo Molnar
2008-04-15 21:06 ` Linus Torvalds
2008-04-15 21:13 ` Ingo Molnar
2008-04-15 21:24 ` Ingo Molnar
2008-04-15 21:42 ` Christoph Lameter
2008-04-15 21:55 ` Ingo Molnar
2008-04-15 22:06 ` Christoph Lameter
2008-04-15 22:13 ` Ingo Molnar
2008-04-15 22:27 ` Christoph Lameter
2008-04-15 22:32 ` Ingo Molnar
2008-04-15 23:22 ` Christoph Lameter
2008-04-15 23:27 ` Ingo Molnar
2008-04-15 23:32 ` Christoph Lameter
2008-04-16 0:04 ` Christoph Lameter
2008-04-15 23:18 ` Yinghai Lu
2008-04-16 0:03 ` [patch] mm: sparsemem memory_present() memory corruption fix Ingo Molnar
2008-04-16 0:10 ` Christoph Lameter
2008-04-16 0:18 ` Ingo Molnar
2008-04-16 0:32 ` Yinghai Lu
2008-04-16 0:44 ` Ingo Molnar
2008-04-16 0:46 ` Christoph Lameter
2008-04-16 0:52 ` Ingo Molnar
2008-04-16 1:17 ` Ingo Molnar
2008-04-16 1:30 ` Yinghai Lu
2008-04-16 2:00 ` Yinghai Lu
2008-04-16 2:20 ` KAMEZAWA Hiroyuki
2008-04-16 0:56 ` Yinghai Lu
2008-04-16 1:02 ` Ingo Molnar
2008-04-16 1:17 ` Yinghai Lu
2008-04-16 0:19 ` Christoph Lameter
2008-04-16 0:33 ` Yinghai Lu
2008-04-16 0:36 ` Ingo Molnar
2008-04-16 0:34 ` Ingo Molnar
2008-04-16 0:40 ` Ingo Molnar
2008-04-16 0:45 ` Christoph Lameter
2008-04-16 0:52 ` Ingo Molnar
2008-04-16 1:14 ` Ingo Molnar
2008-04-16 2:45 ` Linus Torvalds
2008-04-16 1:48 ` KAMEZAWA Hiroyuki
2008-04-16 14:05 ` Mel Gorman [this message]
2008-04-16 15:03 ` Ingo Molnar
2008-04-15 20:54 ` [bug] SLUB + mm/slab.c boot crash in -rc9 Christoph Lameter
2008-04-15 20:58 ` Ingo Molnar
2008-04-15 21:08 ` Ingo Molnar
2008-04-15 20:23 ` Ingo Molnar
2008-04-11 19:26 ` [bug] mm/slab.c boot crash in -git, "kernel BUG at mm/slab.c:2103!" Christoph Lameter
2008-04-11 19:25 ` Christoph Lameter
2008-04-15 5:49 ` Ingo Molnar
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=20080416140512.GA1438@csn.ul.ie \
--to=mel@csn.ul.ie \
--cc=Yinghai.Lu@sun.com \
--cc=akpm@linux-foundation.org \
--cc=apw@shadowen.org \
--cc=clameter@sgi.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=npiggin@suse.de \
--cc=penberg@cs.helsinki.fi \
--cc=rjw@sisk.pl \
--cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.