From: Ye Bin
ohos inclusion
category: feature
feature: ARM kaslr support
issue: #I3ZXZF
CVE: NA
-------------------------------------------------
Fix memtop calculate, when there is no memory top info,
we can't use zero instead it.
Signed-off-by: Ye Bin
Reviewed-by: Jing Xiangfeng
Signed-off-by: zhangyi (F)
Signed-off-by: Cui GaoSheng
Reviewed-by: Xiu Jianfeng
Signed-off-by: Chen Jun
Signed-off-by: Yu Changchun
---
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 6a4c60b22908..a4446202332f 100644
--- a/arch/arm/boot/compressed/kaslr.c
+++ b/arch/arm/boot/compressed/kaslr.c
@@ -316,7 +316,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 (fdt_check_header(fdt))
return 0;
@@ -393,8 +393,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);
--
2.22.0