Commit 436eeae0 authored by Rijo Thomas's avatar Rijo Thomas Committed by Jens Wiklander
Browse files

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: 757cc3e9 ("tee: add AMD-TEE driver")
Tested-by: default avatarSourabh Das <sourabh.das@amd.com>
Signed-off-by: default avatarRijo Thomas <Rijo-john.Thomas@amd.com>
Acked-by: default avatarSumit Garg <sumit.garg@linaro.org>
Signed-off-by: default avatarJens Wiklander <jens.wiklander@linaro.org>
parent f1fcbaa1
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -122,12 +122,14 @@ struct tee_cmd_unmap_shared_mem {
 * @hi_addr:        [in] bits [63:32] of the physical address of the TA binary
 * @size:           [in] size of TA binary in bytes
 * @ta_handle:      [out] return handle of the loaded TA
 * @return_origin:  [out] origin of return code after TEE processing
 */
struct tee_cmd_load_ta {
	u32 low_addr;
	u32 hi_addr;
	u32 size;
	u32 ta_handle;
	u32 return_origin;
};

/**
+17 −13
Original line number Diff line number Diff line
@@ -423,7 +423,10 @@ int handle_load_ta(void *data, u32 size, struct tee_ioctl_open_session_arg *arg)
	if (ret) {
		arg->ret_origin = TEEC_ORIGIN_COMMS;
		arg->ret = TEEC_ERROR_COMMUNICATION;
	} else if (arg->ret == TEEC_SUCCESS) {
	} else {
		arg->ret_origin = load_cmd.return_origin;

		if (arg->ret == TEEC_SUCCESS) {
			ret = get_ta_refcount(load_cmd.ta_handle);
			if (!ret) {
				arg->ret_origin = TEEC_ORIGIN_COMMS;
@@ -438,6 +441,7 @@ int handle_load_ta(void *data, u32 size, struct tee_ioctl_open_session_arg *arg)
				set_session_id(load_cmd.ta_handle, 0, &arg->session);
			}
		}
	}
	mutex_unlock(&ta_refcount_mutex);

	pr_debug("load TA: TA handle = 0x%x, RO = 0x%x, ret = 0x%x\n",