From: Ye Bin yebin10@huawei.com
hulk inclusion commit 88bf5c03832d56c68fac61e4ae97158b3332bd63 category: feature feature: ARM kaslr support bugzilla: https://gitee.com/openeuler/kernel/issues/I8KNA9 CVE: NA
-------------------------------------------------
Fix memtop calculate, when there is no memory top info, we can't use zero instead it.
Signed-off-by: Ye Bin yebin10@huawei.com Reviewed-by: Jing Xiangfeng jingxiangfeng@huawei.com Signed-off-by: zhangyi (F) yi.zhang@huawei.com Signed-off-by: Cui GaoSheng cuigaosheng1@huawei.com Reviewed-by: Xiu Jianfeng xiujianfeng@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com Signed-off-by: Felix Fu fuzhen5@huawei.com --- arch/arm/boot/compressed/kaslr.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/arm/boot/compressed/kaslr.c b/arch/arm/boot/compressed/kaslr.c index cd9915ff038b..caefec2b4219 100644 --- a/arch/arm/boot/compressed/kaslr.c +++ b/arch/arm/boot/compressed/kaslr.c @@ -317,7 +317,7 @@ u32 kaslr_early_init(u32 *kaslr_offset, u32 image_base, u32 image_size, const char *command_line; const char *p; int chosen, len; - u32 lowmem_top, count, num; + u32 lowmem_top, count, num, mem_fdt;
if (IS_ENABLED(CONFIG_EFI_STUB)) { extern u32 __efi_kaslr_offset; @@ -401,8 +401,11 @@ u32 kaslr_early_init(u32 *kaslr_offset, u32 image_base, u32 image_size, }
/* check the memory nodes for the size of the lowmem region */ - regions.pa_end = min(regions.pa_end, get_memory_end(fdt)) - - regions.image_size; + mem_fdt = get_memory_end(fdt); + if (mem_fdt) + regions.pa_end = min(regions.pa_end, mem_fdt) - regions.image_size; + else + regions.pa_end = regions.pa_end - regions.image_size;
puthex32(regions.image_size); puthex32(regions.pa_start);