aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArve Hjønnevåg2012-12-06 22:46:49 -0600
committerArve Hjønnevåg2013-02-22 17:27:50 -0600
commit56063b2f83a2f33ca89f0629f138c951fbca5752 (patch)
tree51d418856ffba4b8cddf22a7ec36266ba484f9e0
parent9e9f90c125b71a2c3e118c05e58b0cb3bbd53d16 (diff)
downloadkernel-common-56063b2f83a2f33ca89f0629f138c951fbca5752.tar.gz
kernel-common-56063b2f83a2f33ca89f0629f138c951fbca5752.tar.xz
kernel-common-56063b2f83a2f33ca89f0629f138c951fbca5752.zip
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 17bb8b2960c..cc76ec03e52 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -956,6 +956,28 @@ void __init sanity_check_meminfo(void)
956 struct membank *bank = &meminfo.bank[j]; 956 struct membank *bank = &meminfo.bank[j];
957 *bank = meminfo.bank[i]; 957 *bank = meminfo.bank[i];
958 958
959#ifdef CONFIG_SPARSEMEM
960 if (pfn_to_section_nr(bank_pfn_start(bank)) !=
961 pfn_to_section_nr(bank_pfn_end(bank) - 1)) {
962 phys_addr_t sz;
963 unsigned long start_pfn = bank_pfn_start(bank);
964 unsigned long end_pfn = SECTION_ALIGN_UP(start_pfn + 1);
965 sz = ((phys_addr_t)(end_pfn - start_pfn) << PAGE_SHIFT);
966
967 if (meminfo.nr_banks >= NR_BANKS) {
968 pr_crit("NR_BANKS too low, ignoring %lld bytes of memory\n",
969 (unsigned long long)(bank->size - sz));
970 } else {
971 memmove(bank + 1, bank,
972 (meminfo.nr_banks - i) * sizeof(*bank));
973 meminfo.nr_banks++;
974 bank[1].size -= sz;
975 bank[1].start = __pfn_to_phys(end_pfn);
976 }
977 bank->size = sz;
978 }
979#endif
980
959 if (bank->start > ULONG_MAX) 981 if (bank->start > ULONG_MAX)
960 highmem = 1; 982 highmem = 1;
961 983