Panic if platform specific BL3-0 handling fails

The return value of bl2_plat_handle_bl30() used to be ignored.
This patch modifies the function load_bl30() so that it now
checks this return value and returns it to bl2_main().

This patch also unifies the error handling code across the
load_blx() functions so that they return a status code in all
cases and bl2_main() has the sole responsibility of panicking
if appropriate.

Change-Id: I2b26cdf65afa443b48c7da1fa7da8db956071bfb
This commit is contained in:
Sandrine Bailleux 2015-03-26 11:07:09 +00:00 committed by Dan Handley
parent 9c7eecce72
commit bcb79b9041

View File

@ -205,23 +205,28 @@ static int load_bl30(void)
&bl30_image_info, &bl30_image_info,
NULL); NULL);
if (e == 0) { if (e)
#if TRUSTED_BOARD_BOOT return e;
e = auth_verify_obj(AUTH_BL30_IMG,
bl30_image_info.image_base,
bl30_image_info.image_size);
if (e) {
ERROR("Failed to authenticate BL3-0 image.\n");
panic();
}
/* After working with data, invalidate the data cache */ #if TRUSTED_BOARD_BOOT
inv_dcache_range(bl30_image_info.image_base, e = auth_verify_obj(AUTH_BL30_IMG,
(size_t)bl30_image_info.image_size); bl30_image_info.image_base,
bl30_image_info.image_size);
if (e) {
ERROR("Failed to authenticate BL3-0 image.\n");
return e;
}
/* After working with data, invalidate the data cache */
inv_dcache_range(bl30_image_info.image_base,
(size_t)bl30_image_info.image_size);
#endif /* TRUSTED_BOARD_BOOT */ #endif /* TRUSTED_BOARD_BOOT */
/* The subsequent handling of BL3-0 is platform specific */ /* The subsequent handling of BL3-0 is platform specific */
bl2_plat_handle_bl30(&bl30_image_info); e = bl2_plat_handle_bl30(&bl30_image_info);
if (e) {
ERROR("Failure in platform-specific handling of BL3-0 image.\n");
return e;
} }
#endif /* BL30_BASE */ #endif /* BL30_BASE */
@ -256,25 +261,25 @@ static int load_bl31(bl31_params_t *bl2_to_bl31_params,
BL31_BASE, BL31_BASE,
bl2_to_bl31_params->bl31_image_info, bl2_to_bl31_params->bl31_image_info,
bl31_ep_info); bl31_ep_info);
if (e)
return e;
if (e == 0) {
#if TRUSTED_BOARD_BOOT #if TRUSTED_BOARD_BOOT
e = auth_verify_obj(AUTH_BL31_IMG, e = auth_verify_obj(AUTH_BL31_IMG,
bl2_to_bl31_params->bl31_image_info->image_base, bl2_to_bl31_params->bl31_image_info->image_base,
bl2_to_bl31_params->bl31_image_info->image_size); bl2_to_bl31_params->bl31_image_info->image_size);
if (e) { if (e) {
ERROR("Failed to authenticate BL3-1 image.\n"); ERROR("Failed to authenticate BL3-1 image.\n");
panic(); return e;
} }
/* After working with data, invalidate the data cache */ /* After working with data, invalidate the data cache */
inv_dcache_range(bl2_to_bl31_params->bl31_image_info->image_base, inv_dcache_range(bl2_to_bl31_params->bl31_image_info->image_base,
(size_t)bl2_to_bl31_params->bl31_image_info->image_size); (size_t)bl2_to_bl31_params->bl31_image_info->image_size);
#endif /* TRUSTED_BOARD_BOOT */ #endif /* TRUSTED_BOARD_BOOT */
bl2_plat_set_bl31_ep_info(bl2_to_bl31_params->bl31_image_info, bl2_plat_set_bl31_ep_info(bl2_to_bl31_params->bl31_image_info,
bl31_ep_info); bl31_ep_info);
}
return e; return e;
} }
@ -309,30 +314,31 @@ static int load_bl32(bl31_params_t *bl2_to_bl31_params)
bl2_to_bl31_params->bl32_image_info, bl2_to_bl31_params->bl32_image_info,
bl2_to_bl31_params->bl32_ep_info); bl2_to_bl31_params->bl32_ep_info);
if (e == 0) { if (e)
#if TRUSTED_BOARD_BOOT return e;
/* Image is present. Check if there is a valid certificate */
if (bl32_cert_error) {
ERROR("Failed to authenticate BL3-2 certificates.\n");
panic();
}
e = auth_verify_obj(AUTH_BL32_IMG, #if TRUSTED_BOARD_BOOT
bl2_to_bl31_params->bl32_image_info->image_base, /* Image is present. Check if there is a valid certificate */
bl2_to_bl31_params->bl32_image_info->image_size); if (bl32_cert_error) {
if (e) { ERROR("Failed to authenticate BL3-2 certificates.\n");
ERROR("Failed to authenticate BL3-2 image.\n"); return bl32_cert_error;
panic(); }
}
/* After working with data, invalidate the data cache */ e = auth_verify_obj(AUTH_BL32_IMG,
inv_dcache_range(bl2_to_bl31_params->bl32_image_info->image_base, bl2_to_bl31_params->bl32_image_info->image_base,
bl2_to_bl31_params->bl32_image_info->image_size);
if (e) {
ERROR("Failed to authenticate BL3-2 image.\n");
return e;
}
/* After working with data, invalidate the data cache */
inv_dcache_range(bl2_to_bl31_params->bl32_image_info->image_base,
(size_t)bl2_to_bl31_params->bl32_image_info->image_size); (size_t)bl2_to_bl31_params->bl32_image_info->image_size);
#endif /* TRUSTED_BOARD_BOOT */ #endif /* TRUSTED_BOARD_BOOT */
bl2_plat_set_bl32_ep_info( bl2_plat_set_bl32_ep_info(
bl2_to_bl31_params->bl32_image_info, bl2_to_bl31_params->bl32_image_info,
bl2_to_bl31_params->bl32_ep_info); bl2_to_bl31_params->bl32_ep_info);
}
#endif /* BL32_BASE */ #endif /* BL32_BASE */
return e; return e;
@ -361,23 +367,24 @@ static int load_bl33(bl31_params_t *bl2_to_bl31_params)
bl2_to_bl31_params->bl33_image_info, bl2_to_bl31_params->bl33_image_info,
bl2_to_bl31_params->bl33_ep_info); bl2_to_bl31_params->bl33_ep_info);
if (e == 0) { if (e)
return e;
#if TRUSTED_BOARD_BOOT #if TRUSTED_BOARD_BOOT
e = auth_verify_obj(AUTH_BL33_IMG, e = auth_verify_obj(AUTH_BL33_IMG,
bl2_to_bl31_params->bl33_image_info->image_base, bl2_to_bl31_params->bl33_image_info->image_base,
bl2_to_bl31_params->bl33_image_info->image_size); bl2_to_bl31_params->bl33_image_info->image_size);
if (e) { if (e) {
ERROR("Failed to authenticate BL3-3 image.\n"); ERROR("Failed to authenticate BL3-3 image.\n");
panic(); return e;
} }
/* After working with data, invalidate the data cache */ /* After working with data, invalidate the data cache */
inv_dcache_range(bl2_to_bl31_params->bl33_image_info->image_base, inv_dcache_range(bl2_to_bl31_params->bl33_image_info->image_base,
(size_t)bl2_to_bl31_params->bl33_image_info->image_size); (size_t)bl2_to_bl31_params->bl33_image_info->image_size);
#endif /* TRUSTED_BOARD_BOOT */ #endif /* TRUSTED_BOARD_BOOT */
bl2_plat_set_bl33_ep_info(bl2_to_bl31_params->bl33_image_info, bl2_plat_set_bl33_ep_info(bl2_to_bl31_params->bl33_image_info,
bl2_to_bl31_params->bl33_ep_info); bl2_to_bl31_params->bl33_ep_info);
}
return e; return e;
} }