From e31f6193bbf2e1ce835b188629406469ce4bdb2c Mon Sep 17 00:00:00 2001 From: Jack Cheung Date: Mon, 12 Dec 2011 17:23:31 -0800 Subject: [PATCH] arm: Init SPARSEMEM section for removed memory If a memblock has been removed with memblock_remove, it will be skipped in 'for_each_memblock'. If a SPARSEMEM section is completely enclosed within this removed memblock, memory_present will never be called and the section will never be initialized. This will cause garbage dereferences later on. This change loops on the memory banks, instead of the memblocks. Memory banks always exist, regardless of memblock_remove and ensure that all SPARSEMEM sections will be initialized, even if they are removed later. Change-Id: I1b7b0418a7e752f5bf69c3ec2ea8ea17e8ecfec5 Signed-off-by: Jack Cheung (cherry picked from commit 7245af9e71b1202d1a972a0bcebea073ce80899a) --- arch/arm/mm/init.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 0bb0f6a7861..502457c7296 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -332,11 +332,12 @@ static void __init arm_memory_present(void) #else static void __init arm_memory_present(void) { - struct memblock_region *reg; - - for_each_memblock(memory, reg) - memory_present(0, memblock_region_memory_base_pfn(reg), - memblock_region_memory_end_pfn(reg)); + struct meminfo *mi = &meminfo; + int i; + for_each_bank(i, mi) { + memory_present(0, bank_pfn_start(&mi->bank[i]), + bank_pfn_end(&mi->bank[i])); + } } #endif