From fe941adbc0463dabb94e94536dadb15f62908b0c Mon Sep 17 00:00:00 2001 From: Mihir Joshi Date: Mon, 23 Jul 2018 16:14:10 -0700 Subject: tlk_driver: propagate TLK error code to user-app Bug 2186806 Tests Tested locally by turning NS DRAM ranges feature ON/OFF and testing userspace binaries Change-Id: I52687f865cf205d158fbf2126c1bb0833ef772d2 Signed-off-by: Mihir Joshi Reviewed-on: https://git-master.nvidia.com/r/1784276 (cherry picked from commit e9dd22e4eddc803488d4f4d2315e23c1de9e2f01) Reviewed-on: https://git-master.nvidia.com/r/1793791 Reviewed-by: mobile promotions Tested-by: mobile promotions --- security/tlk_driver/ote_comms.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'security') diff --git a/security/tlk_driver/ote_comms.c b/security/tlk_driver/ote_comms.c index 9b16565c5..71fb0f6ea 100644 --- a/security/tlk_driver/ote_comms.c +++ b/security/tlk_driver/ote_comms.c @@ -158,6 +158,7 @@ static void do_smc(struct te_request *request, struct tlk_device *dev) { uint32_t smc_args; uint32_t smc_params = 0; + uint32_t retval = 0; smc_args = (uintptr_t)request - (uintptr_t)dev->req_addr; if (request->params) { @@ -165,7 +166,23 @@ static void do_smc(struct te_request *request, struct tlk_device *dev) (uintptr_t)request->params - (uintptr_t)dev->req_addr; } - (void)tlk_send_smc(request->type, smc_args, smc_params); + retval = tlk_send_smc(request->type, smc_args, smc_params); + + /** + * Check for return code from TLK kernel and propagate to NS userspace + * + * Under certain situations, TLK kernel may return an error code + * _without_ updating the shared request buffer. + * + * This could give a false impression to the user-app about status of + * the request (if default value of request->result is OTE_SUCCESS). + * + * Propagate the error code to NS user-app in case of such scenario. + */ + if ((retval != OTE_SUCCESS) && (request->result == OTE_SUCCESS)) { + request->result = retval; + request->result_origin = OTE_RESULT_ORIGIN_KERNEL; + } } void tlk_restore_keyslots(void) -- cgit v1.2.2