]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
imx: hab: Check if IVT header is HABv4
authorBreno Lima <breno.lima@nxp.com>
Thu, 25 Mar 2021 09:30:12 +0000 (17:30 +0800)
committerStefano Babic <sbabic@denx.de>
Thu, 8 Apr 2021 07:18:29 +0000 (09:18 +0200)
The HABv4 implementation in ROM checks if HAB major version
in IVT header is 4.x.

The current implementation in hab.c code is only validating
HAB v4.0 and HAB v4.1 and may be incompatible with newer
HABv4 versions.

Modify verify_ivt_header() function to align with HABv4
implementation in ROM code.

Signed-off-by: Breno Lima <breno.lima@nxp.com>
Reviewed-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
arch/arm/include/asm/mach-imx/hab.h
arch/arm/mach-imx/hab.c

index c4393ef4435034342b575e2077f7697302f5d13a..62218818f91a2e047488f417fd1d2e9e9f61ad33 100644 (file)
@@ -18,8 +18,6 @@
  */
 #define IVT_HEADER_MAGIC       0xD1
 #define IVT_TOTAL_LENGTH       0x20
-#define IVT_HEADER_V1          0x40
-#define IVT_HEADER_V2          0x41
 
 struct __packed ivt_header {
        uint8_t         magic;
index 264e148ba6b13027630449da3e0fb3fea67889f4..5f46df0f8bd1fc51831a1bd85e79d02ffaa28f95 100644 (file)
@@ -45,8 +45,7 @@ static int verify_ivt_header(struct ivt_header *ivt_hdr)
        if (be16_to_cpu(ivt_hdr->length) != IVT_TOTAL_LENGTH)
                result = ivt_header_error("bad length", ivt_hdr);
 
-       if (ivt_hdr->version != IVT_HEADER_V1 &&
-           ivt_hdr->version != IVT_HEADER_V2)
+       if ((ivt_hdr->version & HAB_MAJ_MASK) != HAB_MAJ_VER)
                result = ivt_header_error("bad version", ivt_hdr);
 
        return result;