From: Rong Qianfeng Date: Mon, 2 Sep 2024 02:39:35 +0000 (+0800) Subject: arm64/mm: Delete __init region from memblock.reserved X-Git-Tag: v6.12-rc1~221^2~5^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1db9716d44875d31acf29255710e82338560c177;p=thirdparty%2Fkernel%2Flinux.git arm64/mm: Delete __init region from memblock.reserved If CONFIG_ARCH_KEEP_MEMBLOCK is enabled, the memory information in memblock will be retained. We release the __init memory here, and we should also delete the corresponding region in memblock.reserved, which allows debugfs/memblock/reserved to display correct memory information. Signed-off-by: Rong Qianfeng Link: https://lore.kernel.org/r/20240902023940.43227-1-rongqianfeng@vivo.com Signed-off-by: Will Deacon --- diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 9b5ab6818f7f3..aea834a9691a3 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -414,6 +414,12 @@ void __init mem_init(void) void free_initmem(void) { + unsigned long aligned_begin = ALIGN_DOWN((u64)__init_begin, PAGE_SIZE); + unsigned long aligned_end = ALIGN((u64)__init_end, PAGE_SIZE); + + /* Delete __init region from memblock.reserved. */ + memblock_free((void *)aligned_begin, aligned_end - aligned_begin); + free_reserved_area(lm_alias(__init_begin), lm_alias(__init_end), POISON_FREE_INITMEM, "unused kernel");