MLK-16931 imx8m: hab: Fix secure boot build warning
authorYe Li <ye.li@nxp.com>
Wed, 22 Nov 2017 02:37:21 +0000 (20:37 -0600)
committerYe Li <ye.li@nxp.com>
Wed, 22 Nov 2017 02:53:33 +0000 (20:53 -0600)
Found HAB build warnings on mScale, those relate to ARM 64 bits conversion.

arch/arm/imx-common/hab.c: In function ‘csf_is_valid’:
arch/arm/imx-common/hab.c:556:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
!chk_bounds((const uint8_t *)ivt_initial->csf,
^
In file included from arch/arm/imx-common/hab.c:14:0:
arch/arm/imx-common/hab.c:557:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
HAB_HDR_LEN(*(const struct hab_hdr *)ivt_initial->csf),
^
./arch/arm/include/asm/imx-common/hab.h:177:40: note: in definition of macro ‘HAB_HDR_LEN’
((size_t)(((const struct hab_hdr *)&(hdr))->len[0] << 8) \
^~~
arch/arm/imx-common/hab.c:557:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
HAB_HDR_LEN(*(const struct hab_hdr *)ivt_initial->csf),
^
./arch/arm/include/asm/imx-common/hab.h:178:41: note: in definition of macro ‘HAB_HDR_LEN’
+ (size_t)((const struct hab_hdr *)&(hdr))->len[1])
^~~
arch/arm/imx-common/hab.c:563:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
csf_hdr = (const uint8_t *)ivt_initial->csf;

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
arch/arm/imx-common/hab.c

index dfda5ee..c4680f1 100644 (file)
@@ -554,14 +554,14 @@ static int csf_is_valid(int ivt_offset, ulong start_addr, size_t bytes)
        /* Check that the CSF lies within the image bounds */
        if ((start == 0) || (ivt_initial == NULL) ||
            (ivt_initial->csf == 0) ||
-           !chk_bounds((const uint8_t *)ivt_initial->csf,
-                       HAB_HDR_LEN(*(const struct hab_hdr *)ivt_initial->csf),
+           !chk_bounds((const uint8_t *)(ulong)ivt_initial->csf,
+                       HAB_HDR_LEN(*(const struct hab_hdr *)(ulong)ivt_initial->csf),
                        start, end)) {
                puts("Error - CSF lies outside the image bounds\n");
                return 0;
        }
 
-       csf_hdr = (const uint8_t *)ivt_initial->csf;
+       csf_hdr = (const uint8_t *)(ulong)ivt_initial->csf;
 
        if (*csf_hdr == HAB_CMD_HDR) {
                csf_hdr_len = HAB_HDR_LEN(*(const struct hab_hdr *)csf_hdr);