tee: amdtee: Add return_origin to 'struct tee_cmd_load_ta'

After TEE has completed processing of TEE_CMD_ID_LOAD_TA, set proper
value in 'return_origin' argument passed by open_session() call. To do
so, add 'return_origin' field to the structure tee_cmd_load_ta. The
Trusted OS shall update return_origin as part of TEE processing.

This change to 'struct tee_cmd_load_ta' interface requires a similar update
in AMD-TEE Trusted OS's TEE_CMD_ID_LOAD_TA interface.

This patch has been verified on Phoenix Birman setup. On older APUs,
return_origin value will be 0.

Cc: stable@vger.kernel.org
Fixes: 757cc3e9ff1d ("tee: add AMD-TEE driver")
Tested-by: Sourabh Das <sourabh.das@amd.com>
Signed-off-by: Rijo Thomas <Rijo-john.Thomas@amd.com>
Acked-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>

authored by Rijo Thomas and committed by Jens Wiklander 436eeae0 f1fcbaa1

+22 -16
+6 -4
drivers/tee/amdtee/amdtee_if.h
··· 118 118 119 119 /** 120 120 * struct tee_cmd_load_ta - load Trusted Application (TA) binary into TEE 121 - * @low_addr: [in] bits [31:0] of the physical address of the TA binary 122 - * @hi_addr: [in] bits [63:32] of the physical address of the TA binary 123 - * @size: [in] size of TA binary in bytes 124 - * @ta_handle: [out] return handle of the loaded TA 121 + * @low_addr: [in] bits [31:0] of the physical address of the TA binary 122 + * @hi_addr: [in] bits [63:32] of the physical address of the TA binary 123 + * @size: [in] size of TA binary in bytes 124 + * @ta_handle: [out] return handle of the loaded TA 125 + * @return_origin: [out] origin of return code after TEE processing 125 126 */ 126 127 struct tee_cmd_load_ta { 127 128 u32 low_addr; 128 129 u32 hi_addr; 129 130 u32 size; 130 131 u32 ta_handle; 132 + u32 return_origin; 131 133 }; 132 134 133 135 /**
+16 -12
drivers/tee/amdtee/call.c
··· 423 423 if (ret) { 424 424 arg->ret_origin = TEEC_ORIGIN_COMMS; 425 425 arg->ret = TEEC_ERROR_COMMUNICATION; 426 - } else if (arg->ret == TEEC_SUCCESS) { 427 - ret = get_ta_refcount(load_cmd.ta_handle); 428 - if (!ret) { 429 - arg->ret_origin = TEEC_ORIGIN_COMMS; 430 - arg->ret = TEEC_ERROR_OUT_OF_MEMORY; 426 + } else { 427 + arg->ret_origin = load_cmd.return_origin; 431 428 432 - /* Unload the TA on error */ 433 - unload_cmd.ta_handle = load_cmd.ta_handle; 434 - psp_tee_process_cmd(TEE_CMD_ID_UNLOAD_TA, 435 - (void *)&unload_cmd, 436 - sizeof(unload_cmd), &ret); 437 - } else { 438 - set_session_id(load_cmd.ta_handle, 0, &arg->session); 429 + if (arg->ret == TEEC_SUCCESS) { 430 + ret = get_ta_refcount(load_cmd.ta_handle); 431 + if (!ret) { 432 + arg->ret_origin = TEEC_ORIGIN_COMMS; 433 + arg->ret = TEEC_ERROR_OUT_OF_MEMORY; 434 + 435 + /* Unload the TA on error */ 436 + unload_cmd.ta_handle = load_cmd.ta_handle; 437 + psp_tee_process_cmd(TEE_CMD_ID_UNLOAD_TA, 438 + (void *)&unload_cmd, 439 + sizeof(unload_cmd), &ret); 440 + } else { 441 + set_session_id(load_cmd.ta_handle, 0, &arg->session); 442 + } 439 443 } 440 444 } 441 445 mutex_unlock(&ta_refcount_mutex);