m68k: fix ColdFire node shift size calculation
authorGreg Ungerer <gerg@linux-m68k.org>
Tue, 5 Sep 2017 12:57:06 +0000 (22:57 +1000)
committerGreg Ungerer <gerg@linux-m68k.org>
Sun, 5 Nov 2017 22:25:20 +0000 (08:25 +1000)
The m68k pg_data_table is a fix size array defined in arch/m68k/mm/init.c.
Index numbers within it are defined based on memory size. But for Coldfire
these don't take into account a non-zero physical RAM base address, and this
causes us to access past the end of this array at system start time.

Change the node shift calculation so that we keep the index inside its range.

Reported-by: Angelo Dureghello <angelo@sysam.it>
Tested-by: Angelo Dureghello <angelo@sysam.it>
Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
arch/m68k/mm/mcfmmu.c

index 11eb333e699bf90fbf2a56886f9c0c0c4ee70d1c..2925d795d71a2bff61796dd651ecbfe70ca6901f 100644 (file)
@@ -170,7 +170,7 @@ void __init cf_bootmem_alloc(void)
        max_pfn = max_low_pfn = PFN_DOWN(_ramend);
        high_memory = (void *)_ramend;
 
-       m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
+       m68k_virt_to_node_shift = fls(_ramend - 1) - 6;
        module_fixup(NULL, __start_fixup, __stop_fixup);
 
        /* setup bootmem data */