aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArve Hjønnevåg <arve@android.com>2012-12-06 20:46:49 -0800
committerArve Hjønnevåg <arve@android.com>2013-04-29 14:52:29 -0700
commite798c9d8db5397de6208c89b8d3e0cceb5e01bd3 (patch)
treefaa23cd1b3f7eb7fa8a2c028602dba6fc147476f
parent9cfe54fdde629e73deef198c165b14a75df0be47 (diff)
downloadvexpress-lsk-e798c9d8db5397de6208c89b8d3e0cceb5e01bd3.tar.gz
ARM: mm: Split memory banks that span multiple sections when sparsemem is enabled
This fixes a crash in mem_init which assumes all pages in a memory bank are part of the same page array. Signed-off-by: Arve Hjønnevåg <arve@android.com>
-rw-r--r--arch/arm/mm/mmu.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index db0f77d2b5a..37486f03df5 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -998,6 +998,28 @@ void __init sanity_check_meminfo(void)
struct membank *bank = &meminfo.bank[j];
*bank = meminfo.bank[i];
+#ifdef CONFIG_SPARSEMEM
+ if (pfn_to_section_nr(bank_pfn_start(bank)) !=
+ pfn_to_section_nr(bank_pfn_end(bank) - 1)) {
+ phys_addr_t sz;
+ unsigned long start_pfn = bank_pfn_start(bank);
+ unsigned long end_pfn = SECTION_ALIGN_UP(start_pfn + 1);
+ sz = ((phys_addr_t)(end_pfn - start_pfn) << PAGE_SHIFT);
+
+ if (meminfo.nr_banks >= NR_BANKS) {
+ pr_crit("NR_BANKS too low, ignoring %lld bytes of memory\n",
+ (unsigned long long)(bank->size - sz));
+ } else {
+ memmove(bank + 1, bank,
+ (meminfo.nr_banks - i) * sizeof(*bank));
+ meminfo.nr_banks++;
+ bank[1].size -= sz;
+ bank[1].start = __pfn_to_phys(end_pfn);
+ }
+ bank->size = sz;
+ }
+#endif
+
if (bank->start > ULONG_MAX)
highmem = 1;