in amdtee/call.c [351:397]
int handle_open_session(struct tee_ioctl_open_session_arg *arg, u32 *info,
struct tee_param *p)
{
struct tee_cmd_open_session cmd = {0};
int ret;
if (!arg || !info || (!p && arg->num_params))
return -EINVAL;
arg->ret_origin = TEEC_ORIGIN_COMMS;
if (arg->session == 0) {
arg->ret = TEEC_ERROR_GENERIC;
return -EINVAL;
}
ret = tee_params_to_amd_params(p, arg->num_params, &cmd.op);
if (ret) {
pr_err("invalid Params. Abort open session\n");
arg->ret = TEEC_ERROR_BAD_PARAMETERS;
return ret;
}
cmd.ta_handle = get_ta_handle(arg->session);
*info = 0;
ret = psp_tee_process_cmd(TEE_CMD_ID_OPEN_SESSION, (void *)&cmd,
sizeof(cmd), &arg->ret);
if (ret) {
arg->ret = TEEC_ERROR_COMMUNICATION;
} else {
ret = amd_params_to_tee_params(p, arg->num_params, &cmd.op);
if (unlikely(ret)) {
pr_err("open session: failed to copy output\n");
arg->ret = TEEC_ERROR_GENERIC;
return ret;
}
arg->ret_origin = cmd.return_origin;
*info = cmd.session_info;
pr_debug("open session: session info = 0x%x\n", *info);
}
pr_debug("open session: ret = 0x%x RO = 0x%x\n", arg->ret,
arg->ret_origin);
return ret;
}