Unverified Commit 7ddc1326 authored by davidcunado-arm's avatar davidcunado-arm Committed by GitHub
Browse files

Merge pull request #1182 from soby-mathew/sm/opt_tbbr_flush

Unify cache flush code path after image load
parents c9ff97e2 76163b3a
...@@ -200,14 +200,14 @@ size_t image_size(unsigned int image_id) ...@@ -200,14 +200,14 @@ size_t image_size(unsigned int image_id)
#if LOAD_IMAGE_V2 #if LOAD_IMAGE_V2
/******************************************************************************* /*******************************************************************************
* Generic function to load an image at a specific address given * Internal function to load an image at a specific address given
* an image ID and extents of free memory. * an image ID and extents of free memory.
* *
* If the load is successful then the image information is updated. * If the load is successful then the image information is updated.
* *
* Returns 0 on success, a negative error code otherwise. * Returns 0 on success, a negative error code otherwise.
******************************************************************************/ ******************************************************************************/
int load_image(unsigned int image_id, image_info_t *image_data) static int load_image(unsigned int image_id, image_info_t *image_data)
{ {
uintptr_t dev_handle; uintptr_t dev_handle;
uintptr_t image_handle; uintptr_t image_handle;
...@@ -266,17 +266,6 @@ int load_image(unsigned int image_id, image_info_t *image_data) ...@@ -266,17 +266,6 @@ int load_image(unsigned int image_id, image_info_t *image_data)
goto exit; goto exit;
} }
#if !TRUSTED_BOARD_BOOT
/*
* File has been successfully loaded.
* Flush the image to main memory so that it can be executed later by
* any CPU, regardless of cache and MMU state.
* When TBB is enabled the image is flushed later, after image
* authentication.
*/
flush_dcache_range(image_base, image_size);
#endif /* TRUSTED_BOARD_BOOT */
INFO("Image id=%u loaded: %p - %p\n", image_id, (void *) image_base, INFO("Image id=%u loaded: %p - %p\n", image_id, (void *) image_base,
(void *) (image_base + image_size)); (void *) (image_base + image_size));
...@@ -329,18 +318,19 @@ static int load_auth_image_internal(unsigned int image_id, ...@@ -329,18 +318,19 @@ static int load_auth_image_internal(unsigned int image_id,
image_data->image_size); image_data->image_size);
return -EAUTH; return -EAUTH;
} }
#endif /* TRUSTED_BOARD_BOOT */
/* /*
* File has been successfully loaded and authenticated.
* Flush the image to main memory so that it can be executed later by * Flush the image to main memory so that it can be executed later by
* any CPU, regardless of cache and MMU state. * any CPU, regardless of cache and MMU state. If TBB is enabled, then
* Do it only for child images, not for the parents (certificates). * the file has been successfully loaded and authenticated and flush
* only for child images, not for the parents (certificates).
*/ */
if (!is_parent_image) { if (!is_parent_image) {
flush_dcache_range(image_data->image_base, flush_dcache_range(image_data->image_base,
image_data->image_size); image_data->image_size);
} }
#endif /* TRUSTED_BOARD_BOOT */
return 0; return 0;
} }
......
...@@ -205,7 +205,6 @@ int is_mem_free(uintptr_t free_base, size_t free_size, ...@@ -205,7 +205,6 @@ int is_mem_free(uintptr_t free_base, size_t free_size,
#if LOAD_IMAGE_V2 #if LOAD_IMAGE_V2
int load_image(unsigned int image_id, image_info_t *image_data);
int load_auth_image(unsigned int image_id, image_info_t *image_data); int load_auth_image(unsigned int image_id, image_info_t *image_data);
#else #else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment