MLK-21389 imx: hab: Check if IVT header is HABv4

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>
(cherry picked from commit 33f51b401dffa393274a28f9d49a87af3eb02fe0)
This commit is contained in:
Breno Lima 2019-04-07 23:15:33 -03:00 committed by Ye Li
parent 822252fdc1
commit d1515ca9cd
2 changed files with 1 additions and 4 deletions

View File

@ -19,8 +19,6 @@
*/ */
#define IVT_HEADER_MAGIC 0xD1 #define IVT_HEADER_MAGIC 0xD1
#define IVT_TOTAL_LENGTH 0x20 #define IVT_TOTAL_LENGTH 0x20
#define IVT_HEADER_V1 0x40
#define IVT_HEADER_V2 0x41
struct __packed ivt_header { struct __packed ivt_header {
uint8_t magic; uint8_t magic;

View File

@ -47,8 +47,7 @@ static int verify_ivt_header(struct ivt_header *ivt_hdr)
if (be16_to_cpu(ivt_hdr->length) != IVT_TOTAL_LENGTH) if (be16_to_cpu(ivt_hdr->length) != IVT_TOTAL_LENGTH)
result = ivt_header_error("bad length", ivt_hdr); result = ivt_header_error("bad length", ivt_hdr);
if (ivt_hdr->version != IVT_HEADER_V1 && if ((ivt_hdr->version & HAB_MAJ_MASK) != HAB_MAJ_VER)
ivt_hdr->version != IVT_HEADER_V2)
result = ivt_header_error("bad version", ivt_hdr); result = ivt_header_error("bad version", ivt_hdr);
return result; return result;