Skip to content

Commit abd649f

Browse files
committed
Merge tag 'amdtee-fix-for-v6.5' of https://git.linaro.org/people/jens.wiklander/linux-tee into arm/fixes
AMDTEE add return origin to load TA command * tag 'amdtee-fix-for-v6.5' of https://git.linaro.org/people/jens.wiklander/linux-tee: tee: amdtee: Add return_origin to 'struct tee_cmd_load_ta' Link: https://lore.kernel.org/r/20230606075843.GA2792442@rayden Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2 parents 08425ab + 436eeae commit abd649f

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)