From: Anup Patel Date: Fri, 5 Apr 2019 05:49:34 +0000 (+0000) Subject: RISC-V: Fix Maximum Physical Memory 2GiB option for 64bit systems X-Git-Tag: v5.15~6597^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f05badde4e20d2e0f8c39d07a6873b2bfb0754f8;p=platform%2Fkernel%2Flinux-starfive.git RISC-V: Fix Maximum Physical Memory 2GiB option for 64bit systems 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 Reviewed-by: Christoph Hellwig Signed-off-by: Palmer Dabbelt --- diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 5fd8c92..bc7b77e 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -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);