Skip to content

Commit 436eeae

Browse files
Rijo Thomasjenswi-linaro
authored andcommitted
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: 757cc3e ("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>
1 parent f1fcbaa commit 436eeae

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

drivers/tee/amdtee/amdtee_if.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,18 @@ struct tee_cmd_unmap_shared_mem {
118118

119119
/**
120120
* 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
125126
*/
126127
struct tee_cmd_load_ta {
127128
u32 low_addr;
128129
u32 hi_addr;
129130
u32 size;
130131
u32 ta_handle;
132+
u32 return_origin;
131133
};
132134

133135
/**

drivers/tee/amdtee/call.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -423,19 +423,23 @@ int handle_load_ta(void *data, u32 size, struct tee_ioctl_open_session_arg *arg)
423423
if (ret) {
424424
arg->ret_origin = TEEC_ORIGIN_COMMS;
425425
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;
431-
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);
426+
} else {
427+
arg->ret_origin = load_cmd.return_origin;
428+
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+
}
439443
}
440444
}
441445
mutex_unlock(&ta_refcount_mutex);

0 commit comments

Comments
 (0)