From patchwork Wed Nov 29 12:48:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 10082067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BCD0B6020B for ; Wed, 29 Nov 2017 12:50:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF9AD28991 for ; Wed, 29 Nov 2017 12:50:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A47162974F; Wed, 29 Nov 2017 12:50:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 145E429753 for ; Wed, 29 Nov 2017 12:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dPZ9p3JWxWuAodU971QhJSj9n7CinKawcNB+O7vQooA=; b=OCQ6l0EiiyYwp4 G1Did0wFbxEA68U8Z+eDHx+hRHAhRmkRZARa1Q0N2eEG25JzMHf5CWuh1UisXAawMd4Qai7ZVbukU uqRxMgwOWNrW+ZEQUh+MRzs5m/4F+E2we8DFFdepqCAwOFQkqf4HxWar20mhBN0p8e3z7SXnyAE4H WWXyNjA8sBu3/9gqmQ6/dkhHio/KZk40ArNxEv+jctU6lj2jG8GYjQMbOhwmQtPvaZZNki8DnOvsO glLhXjc6A4h5PukkmRRhcS57R6OKHcA8vzYHs1+tLK8GUd2Zc1U0xSBHfmRsJiOx74lkVYokScdWO /5zOpmUU/b2Wjr1tPVrQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eK1p2-0006ET-4m; Wed, 29 Nov 2017 12:50:40 +0000 Received: from mail-he1eur01on0080.outbound.protection.outlook.com ([104.47.0.80] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eK1oA-00048V-Dc for linux-arm-kernel@lists.infradead.org; Wed, 29 Nov 2017 12:49:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=NmgjnR4yMdO20dk4ZPIEXf0f92tT46hQgT7VtJRJJuY=; b=HeXvNAlLlPGaWt190QNk4O+6F61mMLP5Oc4YCHVkpSN6TuQAw4ntzHQwRCEm+EPBf3mtRcUaAOlSKrAOc1pdLRr6YcWtf8M1Uls7u3gSGLpgzD/Gv7s1a4jUDWyzVo8Q3VIhPUFiFW5mDR34n73pdDmHArI276VyNnPM04R0CjY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Volodymyr_Babchuk@epam.com; Received: from EPUAKYIW2556.kyiv.epam.com (85.223.209.56) by VI1PR03MB1773.eurprd03.prod.outlook.com (2a01:111:e400:7bdd::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.282.5; Wed, 29 Nov 2017 12:49:20 +0000 Received: by EPUAKYIW2556.kyiv.epam.com (sSMTP sendmail emulation); Wed, 29 Nov 2017 14:49:16 +0200 From: Volodymyr Babchuk To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, tee-dev@lists.linaro.org, Jens Wiklander Subject: [RESEND PATCH v2 05/14] tee: optee: Update protocol definitions Date: Wed, 29 Nov 2017 14:48:29 +0200 Message-Id: <1511959718-5421-6-git-send-email-volodymyr_babchuk@epam.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511959718-5421-1-git-send-email-volodymyr_babchuk@epam.com> References: <1507923164-12796-1-git-send-email-volodymyr_babchuk@epam.com> <1511959718-5421-1-git-send-email-volodymyr_babchuk@epam.com> MIME-Version: 1.0 X-Originating-IP: [85.223.209.56] X-ClientProxiedBy: AM5PR0502CA0001.eurprd05.prod.outlook.com (2603:10a6:203:91::11) To VI1PR03MB1773.eurprd03.prod.outlook.com (2a01:111:e400:7bdd::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: be26fc07-ab16-44c8-4464-08d537279c5d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(7168020)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603270); SRVR:VI1PR03MB1773; X-Microsoft-Exchange-Diagnostics: 1; VI1PR03MB1773; 3:+outFEoHhIlXQi+pGRrkNh2TV3qtD0eN/EuXYH5IpDgB3gQ5KX1CwSh+QP4dr/xPseGBiiQf+AQH8tBAI9uO656D5PfMFnmn+68Ql1pNlw1CqZkX0E5LBKSjGzan1dC4tXoKqINVgNiGWb7tL70QaeKg5uXHSri1duJdom5stuvb+Z76V74Jo590QK+nYQLEVjn+dSDHU44LcHYgwbRe4Zyxy2x3KDPd0dXm8CXfXUs9isOvnLyVYqq0IIi81R5r; 25:V+YYQqYJetfX69KI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WK6AeZpbTJ3UV7dtY7YisENTn7zqSEF+mqwEceBErRpJDhpcC2hgmfvgj49MxPNNcc5bLtHwYDHxNwVOiW31IYoa1; 4:9/j/WESXEAbm9gBmCRDpBbV841EN28D1vBPh4NUCl5XG5iLkTSH/p2ILd9FQ15qy6sG/nHweNnNOzQxpC6sm3k6h+YIkj0NzrZgVqQvKw1Ue8oZoa9IBh4CPZeLfDJWWQ8DHUMEAnRtgcGd7uSaZjH8dCCarXShWtgEW5KZo9SUTOzrHfy7FgotbBczG0xBg505zO4UnocnNefHcGinkTViZPP0r3G+skHRCE1MF/pl79MPqJnOSeFoscbn+pLvQlgLMgPpi6HIKgYYeWCA72g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231022)(3002001)(10201501046)(6041248)(20161123564025)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123558100)(6072148)(201708071742011); SRVR:VI1PR03MB1773; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:VI1PR03MB1773; X-Forefront-PRVS: 05066DEDBB X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(376002)(346002)(366004)(189002)(199003)(42186006)(53936002)(316002)(4326008)(107886003)(189998001)(16586007)(105586002)(50226002)(6116002)(33646002)(3846002)(106356001)(48376002)(50466002)(76176999)(50986999)(101416001)(86362001)(5660300001)(39060400002)(36756003)(8936002)(6666003)(2950100002)(47776003)(6916009)(66066001)(72206003)(55236003)(81156014)(478600001)(81166006)(97736004)(80792005)(68736007)(2906002)(305945005)(51416003)(122856001)(7736002)(8676002)(52116002)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR03MB1773; H:EPUAKYIW2556.kyiv.epam.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: epam.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR03MB1773; 23:tUSJud14o5dCC4k0yo/BmxHgIkYLemPZOtDk3gLKR?= =?us-ascii?Q?spkODP8Wa59rFPYA+noiRawMriv0/Q0HljIKT2iF+xAD0WOZICCCdGlfO8HF?= =?us-ascii?Q?3gYasOwmM+G3EX5e5xm/zTnR1Pny5zBOwNejKVOUEYoo6900R/GkY0ziXGvi?= =?us-ascii?Q?u3AMYXGnUuf9b+gm+TJI5VB9uecuSbyokqKrfisTlSKEdoobWS7qLa92bPAw?= =?us-ascii?Q?5A9wOZpRM2NjSFSpDTvLRM/j8Wjds2YOwQHArmJ1Q6aX8ROZ2KZ+OzWfYGHl?= =?us-ascii?Q?BgKkRW/Me0QpvnUz3sl8ZDtntZqoIqXz8s1Yhm0mYXRGdBQK7ZQ8vCvoFSxn?= =?us-ascii?Q?T6RFMPmc6/MTLN+ObwQE0LsEtNw7kkdxcOnCD7cLt0SvBBedmCArIeFQeMLX?= =?us-ascii?Q?meaBJW8nqoVwmM4jxe3R31yKd6KdjUwtQnhg2NLkxmEnf0qVzIhFyLbK/H4a?= =?us-ascii?Q?91m5qSD5NzUVbit6Sn2zd1hu16Hrm84BTpV8BGLCtYdKD+7JI8sPjcAZT5k6?= =?us-ascii?Q?5CuJeyKmHj4bUJIAMN5fyuj0JMELPDyqlFyonRRDCnzE6+QHMzk3BR2CZa1H?= =?us-ascii?Q?oZx3KtitXBAtiLhNaErPPAW7lImo3SI7mdc7Uu9mGwxhE3GmaodgX/NVNTk8?= =?us-ascii?Q?P1GBGJPTUrvhMG6nykKYWEQOd9C4aKFeeaQ25DeZyY/+h/QKBQ1aPE8BgK17?= =?us-ascii?Q?evhAnx7+4R1dFtjHqASQLhYvfRkmwMd/viIs+uGfWL6nlnZnKkCAqCbnvYi/?= =?us-ascii?Q?vD1Mj+Ol4MbUSMkO+j0IUv3vfLDyfhE8R5Od6jE2VXN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Y19D3sLtZ9zEktcHweuxqtUb03Yf4bZv7BrbRPpJnrTiWfcnqbeHBWRK4L64rTu4ZBrrzEWiePPo=; 7:tp+ofnoE5jDX3hwMmGa3ep1pIARdN0q8FwgWKW3rBaGRmPJnYPcMibmojGr3MUgl6aWVi1w01o5/NoDamcXpjweQ1TqQtMnGCeEYlMt5qGIjvNzb13B9xM41Ve8lxTPB8AO/eWTrpcOO/erGG/rlfeEvIIHn9sX9mQcbLNbS/TqZ4XuIn6weOgIKQPFZigwsNPqayuvm7DXd5//N1mCeNMxvh70QupEHIaV3FI4eN8uHAD2p8H4YTuU4EczRs5oa SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2017 12:49:20.4403 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be26fc07-ab16-44c8-4464-08d537279c5d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB1773 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171129_044946_889034_C8223653 X-CRM114-Status: GOOD ( 16.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Volodymyr Babchuk , volodymyr_babchuk@epam.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Volodymyr Babchuk There were changes in REE<->OP-TEE ABI recently. Now ABI allows us to pass non-contiguous memory buffers as list of pages to OP-TEE. This can be achieved by using new parameter attribute OPTEE_MSG_ATTR_NONCONTIG. OP-TEE also is able to use all non-secure RAM for shared buffers. This new capability is enabled with OPTEE_SMC_SEC_CAP_DYNAMIC_SHM flag. This patch adds necessary definitions to the protocol definition files at Linux side. Signed-off-by: Volodymyr Babchuk --- drivers/tee/optee/optee_msg.h | 38 ++++++++++++++++++++++++++++++++------ drivers/tee/optee/optee_smc.h | 7 +++++++ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/drivers/tee/optee/optee_msg.h b/drivers/tee/optee/optee_msg.h index dd7a06e..3050490 100644 --- a/drivers/tee/optee/optee_msg.h +++ b/drivers/tee/optee/optee_msg.h @@ -67,11 +67,32 @@ #define OPTEE_MSG_ATTR_META BIT(8) /* - * The temporary shared memory object is not physically contigous and this - * temp memref is followed by another fragment until the last temp memref - * that doesn't have this bit set. + * Pointer to a list of pages used to register user-defined SHM buffer. + * Used with OPTEE_MSG_ATTR_TYPE_TMEM_*. + * buf_ptr should point to the beginning of the buffer. Buffer will contain + * list of page addresses. OP-TEE core can reconstruct contiguous buffer from + * that page addresses list. Page addresses are stored as 64 bit values. + * Last entry on a page should point to the next page of buffer. + * Every entry in buffer should point to a 4k page beginning (12 least + * significant bits must be equal to zero). + * + * 12 least significant bints of optee_msg_param.u.tmem.buf_ptr should hold page + * offset of the user buffer. + * + * So, entries should be placed like members of this structure: + * + * struct page_data { + * uint64_t pages_array[OPTEE_MSG_NONCONTIG_PAGE_SIZE/sizeof(uint64_t) - 1]; + * uint64_t next_page_data; + * }; + * + * Structure is designed to exactly fit into the page size + * OPTEE_MSG_NONCONTIG_PAGE_SIZE which is a standard 4KB page. + * + * The size of 4KB is chosen because this is the smallest page size for ARM + * architectures. If REE uses larger pages, it should divide them to 4KB ones. */ -#define OPTEE_MSG_ATTR_FRAGMENT BIT(9) +#define OPTEE_MSG_ATTR_NONCONTIG BIT(9) /* * Memory attributes for caching passed with temp memrefs. The actual value @@ -94,6 +115,11 @@ #define OPTEE_MSG_LOGIN_APPLICATION_USER 0x00000005 #define OPTEE_MSG_LOGIN_APPLICATION_GROUP 0x00000006 +/* + * Page size used in non-contiguous buffer entries + */ +#define OPTEE_MSG_NONCONTIG_PAGE_SIZE 4096 + /** * struct optee_msg_param_tmem - temporary memory reference parameter * @buf_ptr: Address of the buffer @@ -145,8 +171,8 @@ struct optee_msg_param_value { * * @attr & OPTEE_MSG_ATTR_TYPE_MASK indicates if tmem, rmem or value is used in * the union. OPTEE_MSG_ATTR_TYPE_VALUE_* indicates value, - * OPTEE_MSG_ATTR_TYPE_TMEM_* indicates tmem and - * OPTEE_MSG_ATTR_TYPE_RMEM_* indicates rmem. + * OPTEE_MSG_ATTR_TYPE_TMEM_* indicates @tmem and + * OPTEE_MSG_ATTR_TYPE_RMEM_* indicates @rmem, * OPTEE_MSG_ATTR_TYPE_NONE indicates that none of the members are used. */ struct optee_msg_param { diff --git a/drivers/tee/optee/optee_smc.h b/drivers/tee/optee/optee_smc.h index 069c8e1..7cd3272 100644 --- a/drivers/tee/optee/optee_smc.h +++ b/drivers/tee/optee/optee_smc.h @@ -222,6 +222,13 @@ struct optee_smc_get_shm_config_result { #define OPTEE_SMC_SEC_CAP_HAVE_RESERVED_SHM BIT(0) /* Secure world can communicate via previously unregistered shared memory */ #define OPTEE_SMC_SEC_CAP_UNREGISTERED_SHM BIT(1) + +/* + * Secure world supports commands "register/unregister shared memory", + * secure world accepts command buffers located in any parts of non-secure RAM + */ +#define OPTEE_SMC_SEC_CAP_DYNAMIC_SHM BIT(2) + #define OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES 9 #define OPTEE_SMC_EXCHANGE_CAPABILITIES \ OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES)