Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1394990pxb; Fri, 21 Jan 2022 17:33:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzLhdFTXqTioBykHgqPrtoTB+9rPgPoutQWD5BCcUm0PolPih9EmwigJ+nkpgmTk5hnWe8c X-Received: by 2002:a17:903:18b:b0:14b:36be:e5aa with SMTP id z11-20020a170903018b00b0014b36bee5aamr105053plg.94.1642815183721; Fri, 21 Jan 2022 17:33:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642815183; cv=none; d=google.com; s=arc-20160816; b=iqtVbd1nlCNZXRsfJgI7A0bxDT9ldHtCy+hD9lWV+5cjhVyHlQ6YYwgzx+erx+p1HE zojF60Zr7+tJZDkYwD3uCd11EyvIMf8oeEDdhdAqYlfuMXain1LzVtefVwvbKoGwEiBT 9IJSx3RPPoAckn+56tWb4F339Urk19Cv2SrPd310In9hiJ3gqeeVuBzdeInPhvAKe685 yBJgvQUc6lLxp04TsvKjpc7WhbG4X6BAaebTJm9kat0G1D35zXl5AuYtvQQlw6VfFL3G 6JxkVV5qrA8kX2k+p39MZyLIqmKzHgAuzIDlmYjcmSOWDUruoJIiqnNzbfNLmmRIp+cw 4Cow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Uilb7rtGXgQI2Rp/O4smGnTA3fqRZ18DddOLnlScU0g=; b=npeyaPUlx9iOtZQX1dtwgQMo4gGMB+N8UYa1k9Dz6id8sq41UL5rfo5k4RdUwNEFSs 0FKKa3d5QAeapaiw+KFLVPxkpQIyZx6a6ARRS7c4DZqKTEbX6+RIGNHTCXs1htMcFojd uPDmUxaVK2A111CnDELMXf2ajec6A+3DKB6XVPsUcbZ4/pzkb3yU5I4o5ldYjci+lP// c1DXc3OrZRZhvPm30ULFN3JUGy8qI6qelCYqRLaqJUwEavs4qLrnix3GK5pTdOSqs2DM cgjBNnlXEJ+viHFyynpP4RztxrX3UBCq5hex2rZja2z3iWhzhBinkk3Js6n6xh/Vx7r0 /2NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@forissier-org.20210112.gappssmtp.com header.s=20210112 header.b=tV5Lwg5E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b17si8859513plh.536.2022.01.21.17.32.52; Fri, 21 Jan 2022 17:33:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@forissier-org.20210112.gappssmtp.com header.s=20210112 header.b=tV5Lwg5E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380696AbiAUN2X (ORCPT + 99 others); Fri, 21 Jan 2022 08:28:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380583AbiAUN2W (ORCPT ); Fri, 21 Jan 2022 08:28:22 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8A4BC061574 for ; Fri, 21 Jan 2022 05:28:21 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id az27-20020a05600c601b00b0034d2956eb04so22363497wmb.5 for ; Fri, 21 Jan 2022 05:28:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=forissier-org.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=Uilb7rtGXgQI2Rp/O4smGnTA3fqRZ18DddOLnlScU0g=; b=tV5Lwg5EcH1gBvbj7qCmrvpFck+165EvZrokCuII+O+fTkmh/5D29KVjVLeQM6a2h/ cvixANVSFJnUMSzbhr4HAJ0gkpA1dO1yapOLeD5TPhuaIxaU5DjKPKpJZwMJHMNXtKVD VZaVUJHpL71buon3nniwbIrOriJezYU8AhnenQM30Iq9w269fqiDeo5agxT39pvXTQ20 KofGSEfKrYXng0XfaMu6yPpq3h09PzR6j080TWWRCoUH7VZgnCZaLbElP67Iq0fzS4Gz LvHHtn8TVAkOYLAKP2Fs4UxVCeHnKJkq1kcrvWAAIAxvhitzjTa/f87DU8KwHQrXCKL+ W9jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=Uilb7rtGXgQI2Rp/O4smGnTA3fqRZ18DddOLnlScU0g=; b=seZWYndTfBLKHkPYx9ESXZvfPALyUPa3JR94aGfems8m0/R/NURQM5ONA8zAkKqTSE Mu/j7TE7brIdSkQQ5SntrrEH73p27AsYgyop2eOB7Hw41cKamL+IY53RhwdGiNS/EGkt VIy71L4DBXAiT2eKf7J5jMEfMmES0CtquiStp+1oo9v9KtCRQoJoGtxrSxbmCpuTvae+ XSoDGzw6n2fLb40vWYFKUwoWSC89kEmNcSw6kR8AkcZfJZAyhoWj6Pp2uRNF6v8ugu7v ouiW7sDMF145ypOo4/HOCd8kBpns+nwKRkcTxpdMO5icZHpQHjdbm2WI6P2hKV7oX5Tn qLFQ== X-Gm-Message-State: AOAM532ow4i9SCPNdRZVJoqtePEXP2DS77BHHWwZOdIPKs1BM3G3/lgj QE3UoNgF7Xov9BDsmBiqsB/ckA== X-Received: by 2002:a7b:c118:: with SMTP id w24mr702278wmi.179.1642771700024; Fri, 21 Jan 2022 05:28:20 -0800 (PST) Received: from ?IPV6:2a01:e0a:3cb:7bb0:a60f:d9da:23e6:8bf2? ([2a01:e0a:3cb:7bb0:a60f:d9da:23e6:8bf2]) by smtp.gmail.com with ESMTPSA id h9sm5575074wmq.8.2022.01.21.05.28.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Jan 2022 05:28:19 -0800 (PST) Message-ID: Date: Fri, 21 Jan 2022 14:28:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v2 07/12] optee: use driver internal tee_contex for some rpc Content-Language: en-US To: Sumit Garg , Jens Wiklander Cc: linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org, Herbert Xu , Devaraj Rangasamy , Rijo Thomas , David Howells , Tyler Hicks , Etienne Carriere References: <20220114150824.3578829-1-jens.wiklander@linaro.org> <20220114150824.3578829-8-jens.wiklander@linaro.org> From: Jerome Forissier In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/21/22 13:54, Sumit Garg wrote: > + Jerome, Etienne > > On Fri, 14 Jan 2022 at 20:38, Jens Wiklander wrote: >> >> Uses the new driver internal tee_context when allocating driver private >> shared memory. This decouples the shared memory object from its original >> tee_context. This is needed when the life time of such a memory >> allocation outlives the client tee_context. >> >> Signed-off-by: Jens Wiklander >> --- >> drivers/tee/optee/ffa_abi.c | 16 ++++++++-------- >> drivers/tee/optee/smc_abi.c | 7 ++++--- >> 2 files changed, 12 insertions(+), 11 deletions(-) >> > > I guess with this patch we should no longer see issues [1] reported earlier. Correct. I have tested [1] again in QEMU with this whole series applied and the issue is gone. -- Jerome > > FWIW, > > Reviewed-by: Sumit Garg > > [1] https://github.com/OP-TEE/optee_os/issues/1918 > > -Sumit > >> diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c >> index 88a028d4fb7b..5ec484b42432 100644 >> --- a/drivers/tee/optee/ffa_abi.c >> +++ b/drivers/tee/optee/ffa_abi.c >> @@ -424,6 +424,7 @@ static struct tee_shm_pool *optee_ffa_shm_pool_alloc_pages(void) >> */ >> >> static void handle_ffa_rpc_func_cmd_shm_alloc(struct tee_context *ctx, >> + struct optee *optee, >> struct optee_msg_arg *arg) >> { >> struct tee_shm *shm; >> @@ -439,7 +440,7 @@ static void handle_ffa_rpc_func_cmd_shm_alloc(struct tee_context *ctx, >> shm = optee_rpc_cmd_alloc_suppl(ctx, arg->params[0].u.value.b); >> break; >> case OPTEE_RPC_SHM_TYPE_KERNEL: >> - shm = tee_shm_alloc_priv_kernel_buf(ctx, >> + shm = tee_shm_alloc_priv_kernel_buf(optee->ctx, >> arg->params[0].u.value.b); >> break; >> default: >> @@ -493,14 +494,13 @@ static void handle_ffa_rpc_func_cmd_shm_free(struct tee_context *ctx, >> } >> >> static void handle_ffa_rpc_func_cmd(struct tee_context *ctx, >> + struct optee *optee, >> struct optee_msg_arg *arg) >> { >> - struct optee *optee = tee_get_drvdata(ctx->teedev); >> - >> arg->ret_origin = TEEC_ORIGIN_COMMS; >> switch (arg->cmd) { >> case OPTEE_RPC_CMD_SHM_ALLOC: >> - handle_ffa_rpc_func_cmd_shm_alloc(ctx, arg); >> + handle_ffa_rpc_func_cmd_shm_alloc(ctx, optee, arg); >> break; >> case OPTEE_RPC_CMD_SHM_FREE: >> handle_ffa_rpc_func_cmd_shm_free(ctx, optee, arg); >> @@ -510,12 +510,12 @@ static void handle_ffa_rpc_func_cmd(struct tee_context *ctx, >> } >> } >> >> -static void optee_handle_ffa_rpc(struct tee_context *ctx, u32 cmd, >> - struct optee_msg_arg *arg) >> +static void optee_handle_ffa_rpc(struct tee_context *ctx, struct optee *optee, >> + u32 cmd, struct optee_msg_arg *arg) >> { >> switch (cmd) { >> case OPTEE_FFA_YIELDING_CALL_RETURN_RPC_CMD: >> - handle_ffa_rpc_func_cmd(ctx, arg); >> + handle_ffa_rpc_func_cmd(ctx, optee, arg); >> break; >> case OPTEE_FFA_YIELDING_CALL_RETURN_INTERRUPT: >> /* Interrupt delivered by now */ >> @@ -582,7 +582,7 @@ static int optee_ffa_yielding_call(struct tee_context *ctx, >> * above. >> */ >> cond_resched(); >> - optee_handle_ffa_rpc(ctx, data->data1, rpc_arg); >> + optee_handle_ffa_rpc(ctx, optee, data->data1, rpc_arg); >> cmd = OPTEE_FFA_YIELDING_CALL_RESUME; >> data->data0 = cmd; >> data->data1 = 0; >> diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c >> index 1dbb13b08381..f2ef76451443 100644 >> --- a/drivers/tee/optee/smc_abi.c >> +++ b/drivers/tee/optee/smc_abi.c >> @@ -621,6 +621,7 @@ static void handle_rpc_func_cmd_shm_free(struct tee_context *ctx, >> } >> >> static void handle_rpc_func_cmd_shm_alloc(struct tee_context *ctx, >> + struct optee *optee, >> struct optee_msg_arg *arg, >> struct optee_call_ctx *call_ctx) >> { >> @@ -650,7 +651,7 @@ static void handle_rpc_func_cmd_shm_alloc(struct tee_context *ctx, >> shm = optee_rpc_cmd_alloc_suppl(ctx, sz); >> break; >> case OPTEE_RPC_SHM_TYPE_KERNEL: >> - shm = tee_shm_alloc_priv_kernel_buf(ctx, sz); >> + shm = tee_shm_alloc_priv_kernel_buf(optee->ctx, sz); >> break; >> default: >> arg->ret = TEEC_ERROR_BAD_PARAMETERS; >> @@ -746,7 +747,7 @@ static void handle_rpc_func_cmd(struct tee_context *ctx, struct optee *optee, >> switch (arg->cmd) { >> case OPTEE_RPC_CMD_SHM_ALLOC: >> free_pages_list(call_ctx); >> - handle_rpc_func_cmd_shm_alloc(ctx, arg, call_ctx); >> + handle_rpc_func_cmd_shm_alloc(ctx, optee, arg, call_ctx); >> break; >> case OPTEE_RPC_CMD_SHM_FREE: >> handle_rpc_func_cmd_shm_free(ctx, arg); >> @@ -775,7 +776,7 @@ static void optee_handle_rpc(struct tee_context *ctx, >> >> switch (OPTEE_SMC_RETURN_GET_RPC_FUNC(param->a0)) { >> case OPTEE_SMC_RPC_FUNC_ALLOC: >> - shm = tee_shm_alloc_priv_kernel_buf(ctx, param->a1); >> + shm = tee_shm_alloc_priv_kernel_buf(optee->ctx, param->a1); >> if (!IS_ERR(shm) && !tee_shm_get_pa(shm, 0, &pa)) { >> reg_pair_from_64(¶m->a1, ¶m->a2, pa); >> reg_pair_from_64(¶m->a4, ¶m->a5, >> -- >> 2.31.1 >>