Received: by 10.223.164.202 with SMTP id h10csp4396733wrb; Wed, 29 Nov 2017 05:51:29 -0800 (PST) X-Google-Smtp-Source: AGs4zMa9UoEYentw9NLiGS5OhFZ2prk9PQ2FjH76Kzonw2zd0qvtCAdcip+XvZRhyNJR5nw9Keqw X-Received: by 10.84.242.144 with SMTP id d16mr2947158pll.375.1511963489353; Wed, 29 Nov 2017 05:51:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511963489; cv=none; d=google.com; s=arc-20160816; b=nC76phNHmUUi2RBP2e87YfzYcfBwbmm2FUGc8sZiOi6kJZ8PkFTdipb8p2iukSxcLg VmsOX13DPxJ5IHgZZp5/Yq4optJTI4JxUku8XT84HDh+bSNVQEJqi5F3Js0mbjULy0ia eMKLSSha6EBHwJjyfRnOnIdonrLgc6BUP6WNEVUdnjS3p/gM+7SAj+2ef0pcXU8Vb9BV ll7TgmjwuT4MhWFswdlRGuI2wgkCIJBZ2uYijgkn99VNITexwmguKNcyf17g0CMX+IlV mGgqXkrUgNB5hDyfTAhAcHiMRJ6mKIdlQ4uCS34GqiOwgQb9tKX+EJkyWUADv6OnIIvg 7ZbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:arc-authentication-results; bh=NmgjnR4yMdO20dk4ZPIEXf0f92tT46hQgT7VtJRJJuY=; b=JVr/pQpTeRy8gFdjXMWEnoLR+w5l2rNx4v0Wi9VAZYExwgX7Opune3ariX7WWPCMTN lVZ3rhQ6SkI61XdokSoc6J6NLEYMs1XTCnflAPx6eHF/9YvQLT6Y01f5OFB6D5XZ47ub YToI8R0PtM5S3m/8ssuG5/QH6B48A3o31mnIo0Owr+fKh0hJCasEuigOZ36UfCo9He43 JYM/G5bfVU5v9Lknpgt9Y8ljkweRMaJAec/wh9tHOBHibD7dCWCgVQ/whTEuoy1Ip1hr SHjaO++MJD5EK+OMeTTerAaL+ioh/wkJLhpQPTI+9UPfHCNUSzOUsqtZtc+ha80STuFN /vgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@epam.com header.s=selector1 header.b=HeXvNAlL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w10si1292035pgc.772.2017.11.29.05.51.18; Wed, 29 Nov 2017 05:51:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@epam.com header.s=selector1 header.b=HeXvNAlL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754870AbdK2Mtc (ORCPT + 70 others); Wed, 29 Nov 2017 07:49:32 -0500 Received: from mail-he1eur01on0058.outbound.protection.outlook.com ([104.47.0.58]:26240 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751958AbdK2MtZ (ORCPT ); Wed, 29 Nov 2017 07:49:25 -0500 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 Cc: Volodymyr Babchuk , volodymyr_babchuk@epam.com 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 Content-Type: text/plain 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/EuXYH5IpDg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D6CshRjd+fcIodDkHAOyCNYYSXmSamrq6GGFnNY39bb/b2+16dx4tihUPzwPTt6jgXKw9AwkhQBP5esxbVSh/9JLHLjKUsaoSWh7MkIwvIp7BVgW6wdILDzVyMQi0rl59Ai6xC7okjz7rD9Po1wscillZTMpkR+kB65taQocesLKc4BI4NFlU3Meh5ZOoCYaCaatx6sLx4K2Eg7wRcZgQUVd2wLo8EYMZFREJhuWK6AeZpbTJ3UV7dtY7YisENTn7zqSEF+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?oZx3KtitXBAtiLhNaErPPAW7lImo3SI7mdc7Uu9mGwxhE3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7wbkmc=;5:Mb5+2N3U1P7C8vymSEaHdbWbfOB0eggqJ/Yx8XvMKVi9pymHPMvYG/YfvLldalcXtRlJkXRRJPGMbAoZotuh6sGv1N1zUVeHc/dBrlO8zQMnwaUmbUXiXoX3TpubkUsPZoWzAMChwOtEqGAH2i1uIgDibQMNKMJk1EA/XAJhy0c=;24:HIQCCBVsAKjtOo67gU2LUa+Z8M2w4RJY19D3sLtZ9zEktcHweuxqtUb03Yf4bZv7BrbRPpJnrTiWfcnqbeHBWRK4L64rTu4ZBrrzEWiePPo=;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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- 2.7.4 From 1581172234401651788@xxx Fri Oct 13 19:35:49 +0000 2017 X-GM-THRID: 1579807725668187688 X-Gmail-Labels: Inbox,Category Forums