]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
RISC-V: Fix Maximum Physical Memory 2GiB option for 64bit systems
authorAnup Patel <Anup.Patel@wdc.com>
Fri, 5 Apr 2019 05:49:34 +0000 (05:49 +0000)
committerPalmer Dabbelt <palmer@sifive.com>
Wed, 10 Apr 2019 16:41:40 +0000 (09:41 -0700)
The Maximum Physical Memory 2GiB option for 64bit systems is currently
broken because kernel hangs at boot-time when this option is enabled
and the underlying system has more than 2GiB memory.

This issue can be easily reproduced on SiFive Unleashed board where
we have 8GiB of memory.

This patch fixes above issue by removing unusable memory region in
setup_bootmem().

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
arch/riscv/mm/init.c

index 5fd8c922e1c225f504c5c81349b49492f8489d19..bc7b77e34d0920f2190c7e8c4edd18658c526703 100644 (file)
@@ -121,6 +121,14 @@ void __init setup_bootmem(void)
                         */
                        memblock_reserve(reg->base, vmlinux_end - reg->base);
                        mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET);
+
+                       /*
+                        * Remove memblock from the end of usable area to the
+                        * end of region
+                        */
+                       if (reg->base + mem_size < end)
+                               memblock_remove(reg->base + mem_size,
+                                               end - reg->base - mem_size);
                }
        }
        BUG_ON(mem_size == 0);