sparc32: Limit memblock allocation to low memory
authorAndreas Larsson <andreas@gaisler.com>
Fri, 5 Feb 2021 13:20:31 +0000 (14:20 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 19 Feb 2021 00:14:31 +0000 (16:14 -0800)
Commit cca079ef8ac29a7c02192d2bad2ffe4c0c5ffdd0 changed sparc32 to use
memblocks instead of bootmem, but also made high memory available via
memblock allocation which does not work together with e.g. phys_to_virt
and can lead to kernel panic.

This changes back to only low memory being allocatable in the early
stages, now using memblock allocation.

Signed-off-by: Andreas Larsson <andreas@gaisler.com>
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc/mm/init_32.c

index eb2946b1df8a43a792a08eb083d28127d066049a..6139c5700ccc9cf2ac477af4e795b875b88b6f9f 100644 (file)
@@ -197,6 +197,9 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
        size = memblock_phys_mem_size() - memblock_reserved_size();
        *pages_avail = (size >> PAGE_SHIFT) - high_pages;
 
+       /* Only allow low memory to be allocated via memblock allocation */
+       memblock_set_current_limit(max_low_pfn << PAGE_SHIFT);
+
        return max_pfn;
 }