From 46d635e8bd0e797be6b64876d5ea513f8e5aead4 Mon Sep 17 00:00:00 2001 From: Arun KS Date: Fri, 15 Sep 2017 13:52:00 +0530 Subject: [PATCH] arm64: Honor limits set by bootloader Introduce a variable to save bootloader enforced memory limits and restricts adding beyond this boundary during a memory hotplug. Also, export this symbol so that other kernel module have access to it. Change-Id: I28c100644b7287ec4625c4c018b5fffc865e2e72 Signed-off-by: Arun KS [sudaraja@codeaurora.org: check limit with physical address of page] Signed-off-by: Sudarshan Rajagopalan [swatsrid@codeaurora.org: Fix merge conflicts] Signed-off-by: Swathi Sridhar [isaacm@codeaurora.org: Fix merge conflicts/use generic page onlining] Signed-off-by: Isaac J. Manjarres --- arch/arm64/include/asm/memory.h | 3 +++ arch/arm64/mm/init.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index c23c47360664..715d3a770b76 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -189,6 +189,9 @@ extern u64 kimage_vaddr; /* the offset between the kernel virtual and physical mappings */ extern u64 kimage_voffset; +/* physical memory limit imposed by the booloader */ +extern phys_addr_t bootloader_memory_limit; + static inline unsigned long kaslr_offset(void) { return kimage_vaddr - KIMAGE_VADDR; diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 45c00a54909c..3184ceccc288 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -257,6 +257,7 @@ int pfn_valid(unsigned long pfn) EXPORT_SYMBOL(pfn_valid); static phys_addr_t memory_limit = PHYS_ADDR_MAX; +phys_addr_t bootloader_memory_limit; /* * Limit the memory size that was specified via FDT. @@ -349,6 +350,12 @@ void __init arm64_memblock_init(void) memblock_remove(0, memstart_addr); } + /* + * Save bootloader imposed memory limit before we overwirte + * memblock. + */ + bootloader_memory_limit = memblock_end_of_DRAM(); + /* * Apply the memory limit if it was set. Since the kernel may be loaded * high up in memory, add back the kernel region that must be accessible