Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8b05987 authored by Anmolpreet Kaur's avatar Anmolpreet Kaur
Browse files

smcinvoke: Update the correct parameters and result from qseecom



This change takes care of two things:

1.smcinvoke expects result in scm call resp.ret[1] and type in ret[0],
while qseecom expects result in ret[0] and type in ret[1]. To simplify
API interface and code changes in smcinvoke, here internally switch
result and resp_type.

2.In case when a listener request comes from secure side to smcinvoke,
we invoke qseecom for processing of listener request. It maybe the case
that after this request, secure side may request for another callback
request. In this flow, we need to update the correct result from qseecom
as 0 so as to indicate that qseecom's job was successfully finished and now
smcinvoke has to take care of the callback request further. This condition
is again checked at smcinvoke side and decision to marshal out is taken
accordingly.

Change-Id: I5d6be3292ef11ac2d84fd287bb8f1e9f91dc1b56
Signed-off-by: default avatarAnmolpreet Kaur <anmolpre@codeaurora.org>
parent 112597fd
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
/*
 * QTI Secure Execution Environment Communicator (QSEECOM) driver
 *
 * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
 */

#define pr_fmt(fmt) "QSEECOM: %s: " fmt, __func__
@@ -2624,6 +2624,11 @@ static int __qseecom_reentrancy_process_incomplete_cmd(
			pr_warn("get cback req app_id = %d, resp->data = %d\n",
				data->client.app_id, resp->data);
			resp->resp_type = SMCINVOKE_RESULT_INBOUND_REQ_NEEDED;
			/* We are here because scm call sent to TZ has requested
			 * for another callback request. This call has been a
			 * success and hence setting result = 0
			 */
			resp->result = 0;
			break;
		default:
			pr_err("fail:resp res= %d,app_id = %d,lstr = %d\n",
@@ -5335,6 +5340,13 @@ int qseecom_process_listener_from_smcinvoke(struct scm_desc *desc)
		return -EINVAL;
	}

	/*
	 * smcinvoke expects result in scm call resp.ret[1] and type in ret[0],
	 * while qseecom expects result in ret[0] and type in ret[1].
	 * To simplify API interface and code changes in smcinvoke, here
	 * internally switch result and resp_type to let qseecom work with
	 * smcinvoke and upstream scm driver protocol.
	 */
	resp.result = desc->ret[0];	/*req_cmd*/
	resp.resp_type = desc->ret[1]; /*incomplete:unused;blocked:session_id*/
	resp.data = desc->ret[2];	/*listener_id*/
@@ -5355,8 +5367,8 @@ int qseecom_process_listener_from_smcinvoke(struct scm_desc *desc)
		pr_err("Failed on cmd %d for lsnr %d session %d, ret = %d\n",
			(int)desc->ret[0], (int)desc->ret[2],
			(int)desc->ret[1], ret);
	desc->ret[0] = resp.result;
	desc->ret[1] = resp.resp_type;
	desc->ret[0] = resp.resp_type;
	desc->ret[1] = resp.result;
	desc->ret[2] = resp.data;
	return ret;
}
+3 −2
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
 */

#define pr_fmt(fmt) "smcinvoke: %s: " fmt, __func__
@@ -1152,7 +1152,8 @@ static int prepare_send_scm_msg(const uint8_t *in_buf, phys_addr_t in_paddr,
		    desc.ret[0] == QSEOS_RESULT_BLOCKED_ON_LISTENER) {
			ret = qseecom_process_listener_from_smcinvoke(&desc);
			req->result = (int32_t)desc.ret[1];
			if (!req->result) {
			if (!req->result &&
			  desc.ret[0] != SMCINVOKE_RESULT_INBOUND_REQ_NEEDED) {
				dmac_inv_range(in_buf, in_buf + in_buf_len);
				ret = marshal_out_invoke_req(in_buf,
						in_buf_len, req, args_buf);