From: Kevin Cernekee <cernekee@gmail.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: Michael Sundius <msundius@cisco.com>,
David VomLehn <dvomlehn@cisco.com>,
Dave Hansen <dave@linux.vnet.ibm.com>,
Andy Whitcroft <apw@shadowen.org>,
Jon Fraser <jfraser@broadcom.com>, <linux-mips@linux-mips.org>,
<linux-kernel@vger.kernel.org>, <stable@kernel.org>
Subject: [PATCH v2] MIPS: Kernel crashes on boot with SPARSEMEM + HIGHMEM enabled
Date: Thu, 31 Mar 2011 17:27:07 -0700 [thread overview]
Message-ID: <c300b67a7a723369872c0b9a023d0b2e@localhost> (raw)
From: Michael Sundius <msundius@cisco.com>
Fix 3 problems in the MIPS SPARSEMEM implementation:
1) mem_init() sets/clears PG_reserved on all pages in the HIGHMEM range
without checking to see whether the page descriptor actually exists.
2) bootmem_init() never calls memory_present() on HIGHMEM pages, so
page descriptors are never created for them if SPARSEMEM is enabled.
3) bootmem_init() calls memory_present() on lowmem pages before bootmem
is fully set up. This is bad because memory_present() can allocate
bootmem in some circumstances (e.g. if SPARSEMEM_EXTREME ever got
enabled).
Signed-off-by: Michael Sundius <msundius@cisco.com>
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Cc: stable@kernel.org
---
arch/mips/kernel/setup.c | 18 +++++++++++++++++-
arch/mips/mm/init.c | 3 +++
2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 8ad1d56..1f9f902 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -390,7 +390,6 @@ static void __init bootmem_init(void)
/* Register lowmem ranges */
free_bootmem(PFN_PHYS(start), size << PAGE_SHIFT);
- memory_present(0, start, end);
}
/*
@@ -402,6 +401,23 @@ static void __init bootmem_init(void)
* Reserve initrd memory if needed.
*/
finalize_initrd();
+
+ /*
+ * Call memory_present() on all valid ranges, for SPARSEMEM.
+ * This must be done after setting up bootmem, since memory_present()
+ * may allocate bootmem.
+ */
+ for (i = 0; i < boot_mem_map.nr_map; i++) {
+ unsigned long start, end;
+
+ if (boot_mem_map.map[i].type != BOOT_MEM_RAM)
+ continue;
+
+ start = PFN_UP(boot_mem_map.map[i].addr);
+ end = PFN_DOWN(boot_mem_map.map[i].addr
+ + boot_mem_map.map[i].size);
+ memory_present(0, start, end);
+ }
}
#endif /* CONFIG_SGI_IP27 */
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 279599e..78a4cf2 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -392,6 +392,9 @@ void __init mem_init(void)
for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
struct page *page = pfn_to_page(tmp);
+ if (!pfn_valid(tmp))
+ continue;
+
if (!page_is_ram(tmp)) {
SetPageReserved(page);
continue;
--
1.7.4.2
WARNING: multiple messages have this Message-ID (diff)
From: Kevin Cernekee <cernekee@gmail.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: Michael Sundius <msundius@cisco.com>,
David VomLehn <dvomlehn@cisco.com>,
Dave Hansen <dave@linux.vnet.ibm.com>,
Andy Whitcroft <apw@shadowen.org>,
Jon Fraser <jfraser@broadcom.com>,
linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
stable@kernel.org
Subject: [PATCH v2] MIPS: Kernel crashes on boot with SPARSEMEM + HIGHMEM enabled
Date: Thu, 31 Mar 2011 17:27:07 -0700 [thread overview]
Message-ID: <c300b67a7a723369872c0b9a023d0b2e@localhost> (raw)
Message-ID: <20110401002707.Bku5QuLCeDhNnNKEcOssLZa3HEGs1u3iFovnHUf30aI@z> (raw)
From: Michael Sundius <msundius@cisco.com>
Fix 3 problems in the MIPS SPARSEMEM implementation:
1) mem_init() sets/clears PG_reserved on all pages in the HIGHMEM range
without checking to see whether the page descriptor actually exists.
2) bootmem_init() never calls memory_present() on HIGHMEM pages, so
page descriptors are never created for them if SPARSEMEM is enabled.
3) bootmem_init() calls memory_present() on lowmem pages before bootmem
is fully set up. This is bad because memory_present() can allocate
bootmem in some circumstances (e.g. if SPARSEMEM_EXTREME ever got
enabled).
Signed-off-by: Michael Sundius <msundius@cisco.com>
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Cc: stable@kernel.org
---
arch/mips/kernel/setup.c | 18 +++++++++++++++++-
arch/mips/mm/init.c | 3 +++
2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 8ad1d56..1f9f902 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -390,7 +390,6 @@ static void __init bootmem_init(void)
/* Register lowmem ranges */
free_bootmem(PFN_PHYS(start), size << PAGE_SHIFT);
- memory_present(0, start, end);
}
/*
@@ -402,6 +401,23 @@ static void __init bootmem_init(void)
* Reserve initrd memory if needed.
*/
finalize_initrd();
+
+ /*
+ * Call memory_present() on all valid ranges, for SPARSEMEM.
+ * This must be done after setting up bootmem, since memory_present()
+ * may allocate bootmem.
+ */
+ for (i = 0; i < boot_mem_map.nr_map; i++) {
+ unsigned long start, end;
+
+ if (boot_mem_map.map[i].type != BOOT_MEM_RAM)
+ continue;
+
+ start = PFN_UP(boot_mem_map.map[i].addr);
+ end = PFN_DOWN(boot_mem_map.map[i].addr
+ + boot_mem_map.map[i].size);
+ memory_present(0, start, end);
+ }
}
#endif /* CONFIG_SGI_IP27 */
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 279599e..78a4cf2 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -392,6 +392,9 @@ void __init mem_init(void)
for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
struct page *page = pfn_to_page(tmp);
+ if (!pfn_valid(tmp))
+ continue;
+
if (!page_is_ram(tmp)) {
SetPageReserved(page);
continue;
--
1.7.4.2
next reply other threads:[~2011-04-01 0:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-01 0:27 Kevin Cernekee [this message]
2011-04-01 0:27 ` [PATCH v2] MIPS: Kernel crashes on boot with SPARSEMEM + HIGHMEM enabled Kevin Cernekee
2011-04-01 16:56 ` David Daney
2011-04-01 17:31 ` Kevin Cernekee
2011-04-01 18:41 ` Michael Sundius
2011-04-01 18:48 ` David Daney
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=c300b67a7a723369872c0b9a023d0b2e@localhost \
--to=cernekee@gmail.com \
--cc=apw@shadowen.org \
--cc=dave@linux.vnet.ibm.com \
--cc=dvomlehn@cisco.com \
--cc=jfraser@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=msundius@cisco.com \
--cc=ralf@linux-mips.org \
--cc=stable@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