qemu: Simplify the image size calculation
authorRadoslaw Biernacki <radoslaw.biernacki@linaro.org>
Thu, 17 May 2018 20:19:35 +0000 (22:19 +0200)
committerSandrine Bailleux <sandrine.bailleux@arm.com>
Wed, 18 Sep 2019 13:58:13 +0000 (15:58 +0200)
Patch introduce the macro NS_IMAGE_MAX_SIZE to simplify the image size
calculation. Use of additional parenthesis removes the possibility of
improper calculations due nested macro expansion for subtraction.
In case of platforms with DRAM window over 32bits, patch also removes
potential problems with type casting, as meminfo.image_size is uint32_t
but macro calculations were done in 64bit space.

Signed-off-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>
Change-Id: I2d05a2d9dd6000dba6114df53262995cf85af018

plat/qemu/common/qemu_bl2_mem_params_desc.c
plat/qemu/qemu/include/platform_def.h

index a01f2dc914dcdda9dc2b1bf55b697326a3588aa7..f8b9066dffc4b8f367a1fbdc197c8644281f35cb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -139,8 +139,7 @@ static bl_mem_params_node_t bl2_mem_params_descs[] = {
          SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2, image_info_t,
                                0),
          .image_info.image_base = NS_IMAGE_OFFSET,
-         .image_info.image_max_size = NS_DRAM0_BASE + NS_DRAM0_SIZE -
-                                      NS_IMAGE_OFFSET,
+         .image_info.image_max_size = NS_IMAGE_MAX_SIZE,
 # endif /* !PRELOADED_BL33_BASE */
 
          .next_handoff_image_id = INVALID_IMAGE_ID,
index d7f77cc78d77ca2825b57a9205561bd073aefe66..a90573712f69d3db6745c14b7f473b91a7af38dc 100644 (file)
 # error "Unsupported BL32_RAM_LOCATION_ID value"
 #endif
 
-#define NS_IMAGE_OFFSET                        0x60000000
+#define NS_IMAGE_OFFSET                        (NS_DRAM0_BASE + 0x20000000)
+#define NS_IMAGE_MAX_SIZE              (NS_DRAM0_SIZE - 0x20000000)
 
 #define PLAT_PHY_ADDR_SPACE_SIZE       (1ULL << 32)
 #define PLAT_VIRT_ADDR_SPACE_SIZE      (1ULL << 32)