From cdab8bbfe23255405b0b35cf764eccaa85ab6af1 Mon Sep 17 00:00:00 2001 From: Vijayanand Jitta Date: Wed, 16 Oct 2019 13:02:18 +0530 Subject: [PATCH] arm64: Honor limits set by boot parameter Consider the memory limit enforced by boot parameter and restrict adding beyond this boundary during a memory hotplug. Change-Id: Ibd13e47ee13004381a1ddff649150fae13429c87 Signed-off-by: Vijayanand Jitta Signed-off-by: Isaac J. Manjarres --- arch/arm64/mm/init.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index a91f9963a4b9..a0f485bd5136 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -274,7 +274,16 @@ static void __init update_memory_limit(void) phys_addr_t min_ddr_sz = 0, offline_sz = 0; int t_len = (2 * dt_root_size_cells) * sizeof(__be32); - ram_sz = memblock_phys_mem_size(); + if (memory_limit == PHYS_ADDR_MAX) + ram_sz = memblock_phys_mem_size(); + else if (IS_ALIGNED(memory_limit, MIN_MEMORY_BLOCK_SIZE)) + ram_sz = memory_limit; + else { + WARN(1, "mem-offline is not supported for DDR size %lld\n", + memory_limit); + return; + } + node = of_get_flat_dt_subnode_by_name(dt_root, "mem-offline"); if (node == -FDT_ERR_NOTFOUND) { pr_err("mem-offine node not found in FDT\n"); @@ -434,12 +443,16 @@ void __init arm64_memblock_init(void) memblock_remove(0, memstart_addr); } - update_memory_limit(); /* * Save bootloader imposed memory limit before we overwirte * memblock. */ - bootloader_memory_limit = memblock_end_of_DRAM(); + if (memory_limit == PHYS_ADDR_MAX) + bootloader_memory_limit = memblock_end_of_DRAM(); + else + bootloader_memory_limit = memblock_max_addr(memory_limit); + + update_memory_limit(); /* * Apply the memory limit if it was set. Since the kernel may be loaded