From d93190aa46033a67f4ac4d88fe39fda3bde5c4f4 Mon Sep 17 00:00:00 2001 From: Jerome Forissier Date: Tue, 26 Feb 2019 10:31:03 +0100 Subject: core: user_ta: load_elf(): return meaningful error code If any error is encountered when the TEE core attempts to load a TA from TA storage, the next storage is tried and so on until the TA is successfully loaded or there is no more storage to try. In this case, a generic error code (TEE_ERROR_ITEM_NOT_FOUND) is returned to the caller of load_elf() and ultimately to the client. This is not super useful, especially when debug traces are disabled, because the user has no way to differentiate a true "not found" situation (which might be a configuration or deployement issue) from an issue with the TA file itself or an out-of-memory condition etc. This commit changes the return code of load_elf() to better reflect the errors. When load_elf_from_store() returns TEE_ERROR_ITEM_NOT_FOUND or TEE_ERROR_STORAGE_NOT_AVAILABLE, the next storage is tried. Signed-off-by: Jerome Forissier Reviewed-by: Jens Wiklander Reviewed-by: Etienne Carriere --- core/arch/arm/kernel/user_ta.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'core') diff --git a/core/arch/arm/kernel/user_ta.c b/core/arch/arm/kernel/user_ta.c index 02dcf61e..a9bdae07 100644 --- a/core/arch/arm/kernel/user_ta.c +++ b/core/arch/arm/kernel/user_ta.c @@ -869,7 +869,7 @@ out: /* Loads a single ELF file (main executable or library) */ static TEE_Result load_elf(const TEE_UUID *uuid, struct user_ta_ctx *utc) { - TEE_Result res; + TEE_Result res = TEE_ERROR_ITEM_NOT_FOUND; const struct user_ta_store_ops *op = NULL; SCATTERED_ARRAY_FOREACH(op, ta_stores, struct user_ta_store_ops) { @@ -877,13 +877,10 @@ static TEE_Result load_elf(const TEE_UUID *uuid, struct user_ta_ctx *utc) op->description); res = load_elf_from_store(uuid, op, utc); - if (res == TEE_ERROR_ITEM_NOT_FOUND) - continue; - if (res) { - DMSG("res=0x%x", res); + DMSG("res=0x%x", res); + if (res == TEE_ERROR_ITEM_NOT_FOUND || + res == TEE_ERROR_STORAGE_NOT_AVAILABLE) continue; - } - return res; } -- cgit v1.2.3