powerpc/mm: Check memblock_add against MAX_PHYSMEM_BITS range
authorAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Thu, 21 Jun 2018 08:31:57 +0000 (14:01 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 24 Jul 2018 12:03:16 +0000 (22:03 +1000)
commit6aba0c84ec474534bbae3675e95464958a6c5713
tree7342df971be5f0b1a42dbaf39a11563eaa5aecd3
parent64de5d8d0457c325e2226c9c7efb37b1f772076c
powerpc/mm: Check memblock_add against MAX_PHYSMEM_BITS range

With SPARSEMEM config enabled, we make sure that we don't add sections beyond
MAX_PHYSMEM_BITS range. This results in not building vmemmap mapping for
range beyond max range. But our memblock layer looks the device tree and create
mapping for the full memory range. Prevent this by checking against
MAX_PHSYSMEM_BITS when doing memblock_add.

We don't do similar check for memeblock_reserve_range. If reserve range is beyond
MAX_PHYSMEM_BITS we expect that to be configured with 'nomap'. Any other
reserved range should come from existing memblock ranges which we already
filtered while adding.

This avoids crash as below when running on a system with system ram config above
MAX_PHSYSMEM_BITS

 Unable to handle kernel paging request for data at address 0xc00a001000000440
 Faulting instruction address: 0xc000000001034118
 cpu 0x0: Vector: 300 (Data Access) at [c00000000124fb30]
     pc: c000000001034118: __free_pages_bootmem+0xc0/0x1c0
     lr: c00000000103b258: free_all_bootmem+0x19c/0x22c
     sp: c00000000124fdb0
    msr: 9000000002001033
    dar: c00a001000000440
  dsisr: 40000000
   current = 0xc00000000120dd00
   paca    = 0xc000000001f60000^I irqmask: 0x03^I irq_happened: 0x01
     pid   = 0, comm = swapper
 [c00000000124fe20c00000000103b258 free_all_bootmem+0x19c/0x22c
 [c00000000124fee0c000000001010a68 mem_init+0x3c/0x5c
 [c00000000124ff00c00000000100401c start_kernel+0x298/0x5e4
 [c00000000124ff90c00000000000b57c start_here_common+0x1c/0x520

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/prom.c