From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBEA2C432BE for ; Thu, 26 Aug 2021 14:54:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9088B60EE0 for ; Thu, 26 Aug 2021 14:54:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9088B60EE0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KS304d9Sj280yTjBytzheDecSOWlOQxRMzZwJEy9Hm4=; b=ReUVBWgynxJFp6 8DRlySVyHJYEreAJI67yABuf0yctrhrBSpObqgScThuAkpM1v6xMmENN6rX/TONV2A/hJNfofkM1k usXq8x8Y+48o/xWePFs3ctVEH/q0PdRCu52wG86V5dGnhYVvWC/G71qTgxaFB2qv8Gygj9aFEnaK1 qmmSu8JvY79egYR0aqJ8CGzkhjyVBZEmvcMqA11HiWfa1iIDzwfU1dQqj46ipUIi/DGmWK/522m9M dln8ftyv2zM7y06cl5bSVuJSpUwxbZFWMzEmjcAdoPEtt0IiK9sDUfzo8+UuN1s7AXNgw5ZlnBEGA rqI4homg0qabhlg9c3VQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJGjw-00APma-FK; Thu, 26 Aug 2021 14:52:24 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJGjp-00APl1-Fk for linux-arm-kernel@lists.infradead.org; Thu, 26 Aug 2021 14:52:21 +0000 Received: by mail-lj1-x22b.google.com with SMTP id m4so5607825ljq.8 for ; Thu, 26 Aug 2021 07:52:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Ta1NoD8SNB7CUXQby/YaoqCg3FSl+9VTaHeQNAlA9LY=; b=WDaesmr8YGqAtX/adbODz5Pk8xiiTukN++C1ufxRN5MA3x6uFEnYcis1jUihX8RGRQ xmoNrKwrXuHa3Lw4a1bVIMK9bb0Owukc43tDKD34qZKbZtRx6/5zcm1Uj4NSxxR+xP/O j9cWsV6EzXMiQYlydeEaeiXoeHbtHJ1qh5pfty7thWApPF3rC7NJwhbJPIsi0Xu7+cZF vq1AVvBrQpsH47pAnh7tZMqCRqpAmIhSYI0etMzZZoYEsZ6W/irNgayJHMFv1rs04WdS 86Fxn9R9kU19LjrZvmW8gasgcveiDoEoSpTWQa+vnhVIFMe0zvSPPQ26RS42zeqYG3Is YFwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Ta1NoD8SNB7CUXQby/YaoqCg3FSl+9VTaHeQNAlA9LY=; b=RK/W6uhMMnPR8w0aOHKng6GHCVLuVfKLnV8mMz7xTw0wO1IWzw310xamhH/hv1zYcY Ng4+VwlbiAG07iWy5rjJ3oxdlQBrW93w8m59pRg9Bv3uCjwpqJCFXKB8WKTRDQ9tNnD2 uYepHvRnuH1UwOstML/ke5Y0jDbULNKieWyToJcCQf6LSB93+mZTdYfKuRgFtRI/FyTA WQZAPvbKDZA6ev7qPGjYRs4Js6ONiL1zvaRToSwbk1V1eCMyyxXMRyJwuSvje2LuM1ah iNdGzW/0mu0WKyeM0KgHld8/m1Wt0NBZRn1GWve6KXuBg97aW4b38eHj6zttKbpe+lFl PCTg== X-Gm-Message-State: AOAM532Au6Ih4DfkhcNYyN5umRtFCrLMKhZ5TltVcjfWjnhZiOC3zLe3 45fZ4M+r3JUlWMElvuSTUN44Lg== X-Google-Smtp-Source: ABdhPJyg46f3fFaTVnEE0HqAYT1PDyIzFKiZTxUcGQOrN/lyAJweyUYUg4FFP5z1S0gWot74tIIHWg== X-Received: by 2002:a05:651c:454:: with SMTP id g20mr3509822ljg.142.1629989535748; Thu, 26 Aug 2021 07:52:15 -0700 (PDT) Received: from jade (81-236-179-152-no272.tbcn.telia.com. [81.236.179.152]) by smtp.gmail.com with ESMTPSA id k13sm336704lfg.189.2021.08.26.07.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 07:52:15 -0700 (PDT) Date: Thu, 26 Aug 2021 16:52:13 +0200 From: Jens Wiklander To: Sumit Garg Cc: Linux Kernel Mailing List , linux-arm-kernel , OP-TEE TrustedFirmware , Sudeep Holla , Marc Bonnici , Jerome Forissier , Sughosh Ganu Subject: Re: [PATCH v4 5/5] optee: add FF-A support Message-ID: <20210826145213.GA1739293@jade> References: <20210819110655.739318-1-jens.wiklander@linaro.org> <20210819110655.739318-6-jens.wiklander@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210826_075217_608260_080C0221 X-CRM114-Status: GOOD ( 33.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Aug 25, 2021 at 05:12:45PM +0530, Sumit Garg wrote: > On Thu, 19 Aug 2021 at 16:37, Jens Wiklander wrote: > > > > Adds support for using FF-A [1] as transport to the OP-TEE driver. > > > > Introduces struct optee_msg_param_fmem which carries all information > > needed when OP-TEE is calling FFA_MEM_RETRIEVE_REQ to get the shared > > memory reference mapped by the hypervisor in S-EL2. Register usage is > > also updated to include the information needed. > > > > The FF-A part of this driver is enabled if CONFIG_ARM_FFA_TRANSPORT is > > enabled. > > > > [1] https://developer.arm.com/documentation/den0077/latest > > Signed-off-by: Jens Wiklander > > --- > > drivers/tee/optee/Makefile | 3 +- > > drivers/tee/optee/call.c | 13 +- > > drivers/tee/optee/core.c | 16 +- > > drivers/tee/optee/ffa_abi.c | 907 ++++++++++++++++++++++++++++++ > > drivers/tee/optee/optee_ffa.h | 153 +++++ > > drivers/tee/optee/optee_msg.h | 27 +- > > drivers/tee/optee/optee_private.h | 43 +- > > 7 files changed, 1148 insertions(+), 14 deletions(-) > > create mode 100644 drivers/tee/optee/ffa_abi.c > > create mode 100644 drivers/tee/optee/optee_ffa.h > > [snip] > > --- /dev/null > > +++ b/drivers/tee/optee/ffa_abi.c > > @@ -0,0 +1,907 @@ > > +// SPDX-License-Identifier: GPL-2.0-only > > +/* > > + * Copyright (c) 2021, Linaro Limited > > + */ > > + > > +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include "optee_private.h" > > +#include "optee_ffa.h" > > +#include "optee_rpc_cmd.h" > > + > > +/* > > + * This file implement the FF-A ABI used when communicating with secure world > > + * OP-TEE OS via FF-A. > > + * This file is divided into the follow sections: > > s/follow/following/ Thanks, I'll fix. [snip] > > +static bool optee_ffa_exchange_caps(struct ffa_device *ffa_dev, > > + const struct ffa_dev_ops *ops, > > + unsigned int *rpc_arg_count) > > +{ > > + struct ffa_send_direct_data data = { OPTEE_FFA_EXCHANGE_CAPABILITIES }; > > + int rc; > > + > > + rc = ops->sync_send_receive(ffa_dev, &data); > > + if (rc) { > > + pr_err("Unexpected error %d", rc); > > + return false; > > + } > > + if (data.data0) { > > + pr_err("Unexpected exchange error %lu", data.data0); > > + return false; > > + } > > + > > + *rpc_arg_count = (u8)data.data1; > > Why is this special capability required in case of FF-A? Is it true > that RPC arguments count will be fixed for all RPC commands? It's to allow this driver to preallocate the argument struct used when doing RPC. That way we can avoid the chicken and egg problem of allocating an RPC argumet struct just before doing the real RPC. This is the maximum number of arguments needed by secure world. In case a larger value ever is needed, secure world will be able to supply the needed value. I plan to update the SMC based ABI with this also, but not in the patch set. > > > + > > + return true; > > +} [snip] > > +static int optee_ffa_probe(struct ffa_device *ffa_dev) > > +{ > > + const struct ffa_dev_ops *ffa_ops; > > + unsigned int rpc_arg_count; > > + struct tee_device *teedev; > > + struct optee *optee; > > + int rc; > > + > > + ffa_ops = ffa_dev_ops_get(ffa_dev); > > + if (!ffa_ops) { > > + pr_warn("failed \"method\" init: ffa\n"); > > + return -ENOENT; > > + } > > + > > + if (!optee_ffa_api_is_compatbile(ffa_dev, ffa_ops)) > > + return -EINVAL; > > + > > + if (!optee_ffa_exchange_caps(ffa_dev, ffa_ops, &rpc_arg_count)) > > + return -EINVAL; > => + > > + optee = kzalloc(sizeof(*optee), GFP_KERNEL); > > + if (!optee) { > > + rc = -ENOMEM; > > + goto err; > > + } > > + optee->pool = optee_ffa_config_dyn_shm(); > > + if (IS_ERR(optee->pool)) { > > + rc = PTR_ERR(optee->pool); > > + optee->pool = NULL; > > + goto err; > > + } > > IIUC, with FF-A we will only be supporting dynamic shared memory. So > CFG_CORE_DYN_SHM=y should be enforced in OP-TEE OS when > CFG_CORE_FFA=y, but I don't see that currently. Am I missing > something? You mean in optee_os.git? With FF-A dynamic shared memory is always handled, so that flag in irrelevant in that case. However, feel free to start a discussion on that topic at github. Thanks, Jens _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel