in amdtee/call.c [240:284]
int handle_invoke_cmd(struct tee_ioctl_invoke_arg *arg, u32 sinfo,
struct tee_param *p)
{
struct tee_cmd_invoke_cmd cmd = {0};
int ret;
if (!arg || (!p && arg->num_params))
return -EINVAL;
arg->ret_origin = TEEC_ORIGIN_COMMS;
if (arg->session == 0) {
arg->ret = TEEC_ERROR_BAD_PARAMETERS;
return -EINVAL;
}
ret = tee_params_to_amd_params(p, arg->num_params, &cmd.op);
if (ret) {
pr_err("invalid Params. Abort invoke command\n");
arg->ret = TEEC_ERROR_BAD_PARAMETERS;
return ret;
}
cmd.ta_handle = get_ta_handle(arg->session);
cmd.cmd_id = arg->func;
cmd.session_info = sinfo;
ret = psp_tee_process_cmd(TEE_CMD_ID_INVOKE_CMD, (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("invoke command: failed to copy output\n");
arg->ret = TEEC_ERROR_GENERIC;
return ret;
}
arg->ret_origin = cmd.return_origin;
pr_debug("invoke command: RO = 0x%x ret = 0x%x\n",
arg->ret_origin, arg->ret);
}
return ret;
}