Received: by 10.223.164.202 with SMTP id h10csp4400076wrb; Wed, 29 Nov 2017 05:54:54 -0800 (PST) X-Google-Smtp-Source: AGs4zMYtKCaMKtiV3IphGJ+esocWutlyZgh7O+lRJWawmJBUFvbRcBTkdTV8+izKWBpExpuxDb8s X-Received: by 10.159.249.1 with SMTP id bf1mr2947419plb.401.1511963694271; Wed, 29 Nov 2017 05:54:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511963694; cv=none; d=google.com; s=arc-20160816; b=wgUWhRK+F92BXZJ0j3/hd9G0TAsGfTx74Qv5DJl5H5BU00drTzSVwafOutQgkbeHg/ +DXI8Z5xVsNy0SRNvYeSkGmggnz7BpYtRhm6UZd0GQ6wH6kmOdpFNobu535damdSOfxt ngxqbElqO2E/IHDclz6U506h3EZcqYzmUP8HYx2T+cKeZIijeih+mK1mDfiaGjeT6s9o 3viwgN9xZWOtsO6b8wfr3ahHbJHTiL1+WEYKUA0hlNQ1LJfHB9fxAVMaP05IDOXFnbM0 h662nftr4b4qOI5C9KSYPAaZLQTiZ5qODxTHbc+cXfTq89crVf5qaJc1RiUW+FIoFan9 ibgw== 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=ooTW+TtMuY3279dklQeF1A6BA4wiw7s3xZkBGU7zN8I=; b=BTKX8EDo2keJStJN62UcFw1T4YNcu00jpHRV9HhESYy3ldp8uXirdMAM5C7LxZctD5 wKhzk5O69Jdwa2URszqEgl0NZUg7YDGfWwHJXzQYqm4TaP+BIgIa4OR/3pEmo+AKl66Y VWqrQEp5ZC6RVo+R/WdtTG6KRQ+eOn3awkf+5SK+HUybla52fr2m/MtIHBlZEEdTc8mv obUt5zx6bE35t1/OydsjM8AHhULzyDDLonyKaMV85rNXpCXPq5mUNshkfvpD7cWQwU/8 awIc3aRva2BBqCFBHspH1u5haowVl7hyfJqg2SFxKL8YwPnJL30NCrhUNou5fKjUV0bt w+1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@epam.com header.s=selector1 header.b=D5wNZD5m; 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 k66si1384817pfh.386.2017.11.29.05.54.44; Wed, 29 Nov 2017 05:54:54 -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=D5wNZD5m; 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 S1753498AbdK2Mw6 (ORCPT + 70 others); Wed, 29 Nov 2017 07:52:58 -0500 Received: from mail-db5eur01on0056.outbound.protection.outlook.com ([104.47.2.56]:20011 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752607AbdK2Msx (ORCPT ); Wed, 29 Nov 2017 07:48:53 -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=ooTW+TtMuY3279dklQeF1A6BA4wiw7s3xZkBGU7zN8I=; b=D5wNZD5mXYZdiMwk8Vu71W/qCUEiHmR/Z6Wrfks6EJLfT4LudcCypnw19svQDj0SlAcoiWaeTCFnJ2lvh66XaFB/lSIXcopd0hI3L/UpYNiiPGghrNoTM7pAPd2JmAKk5KXf3Uru7wCbk7oe48edQaoa1NQsWapp7nbY1hRXA3E= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Volodymyr_Babchuk@epam.com; Received: from EPUAKYIW2556.kyiv.epam.com (85.223.209.56) by DB5PR03MB1768.eurprd03.prod.outlook.com (2a01:111:e400:c580::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.260.4; Wed, 29 Nov 2017 12:48:48 +0000 Received: by EPUAKYIW2556.kyiv.epam.com (sSMTP sendmail emulation); Wed, 29 Nov 2017 14:48:44 +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 00/14] tee: optee: add dynamic shared memory support Date: Wed, 29 Nov 2017 14:48:24 +0200 Message-Id: <1511959718-5421-1-git-send-email-volodymyr_babchuk@epam.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507923164-12796-1-git-send-email-volodymyr_babchuk@epam.com> References: <1507923164-12796-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: VI1PR0102CA0002.eurprd01.prod.exchangelabs.com (2603:10a6:802::15) To DB5PR03MB1768.eurprd03.prod.outlook.com (2a01:111:e400:c580::9) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 493f2267-4855-4236-4acd-08d5372789a9 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(7168020)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603199);SRVR:DB5PR03MB1768; X-Microsoft-Exchange-Diagnostics: 1;DB5PR03MB1768;3:Gck3aK7ZkWuSnSgslOigYDVwx/sdp1mlXd6omNUCBus6O6YjhGv/JNdWewUy/zSXVVwYfEUi9ifZ29hXongXBfjF/16NNjN9hCo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53HK1/ftDYFc5gObm0U/hRjL38RIT5p1wXV48HpKZHKa3kcJj7l4v6OmEukOHonsXXLHPinwyk/4m+/z+qcJBEtoK5mT9CMqenRzB748ttz/WgidYygkuomsFa6Bb5g9fvWMOrTdbw05RBtsxHeDZEr9thdLb8Ro0cZftGgy4eQadlgsmQlHJXHiESu53/n+n96QLZCwqkNZD/8KhrBtTWqt0l2xb9wWuCx4v+61QsvQOqtKJ8+tr3iyqIq;4:6k0Ui2He2i+1MooJejI20pc5xsD3uetocj25lBCBMHs2J1RU1eA769WNMcOK2xUPeDoI52rv9kyA4GXVM3o9qCSF7DH7Frs97WofYRD2boEa846yTZ77dkDcOqX9Gqo0ba7kXITmx2mk3g9HqiUEc5j9tK6W5S4L5k9gqGm8tcJJPUr3D28DStyr+vDEuCnpcfe1t+o3Iof/kfJsySWzfCS1cwajMNkPxd37B9JQ+/HOXrMgoWbbUwicPkpPP7jBsoJR7bM47+UdbjmCGe5WZqki3XtkSYajSsJVhwnmYJHwjbUWsha2hMtds/4J/iqCJUzN8+MJgaSqU6ajM2zedw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(278428928389397); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231022)(3002001)(10201501046)(6041248)(20161123564025)(20161123558100)(20161123555025)(20161123560025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DB5PR03MB1768;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:DB5PR03MB1768; X-Forefront-PRVS: 05066DEDBB X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(366004)(376002)(346002)(53754006)(189002)(199003)(966005)(86362001)(101416001)(76176999)(122856001)(50986999)(105586002)(6116002)(68736007)(97736004)(106356001)(305945005)(4326008)(5660300001)(53936002)(66066001)(2906002)(3846002)(189998001)(47776003)(7736002)(6306002)(16586007)(50226002)(2950100002)(8936002)(6666003)(316002)(8676002)(6916009)(80792005)(33646002)(81156014)(81166006)(72206003)(39060400002)(42186006)(107886003)(50466002)(48376002)(55236003)(51416003)(52116002)(36756003)(478600001)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:DB5PR03MB1768;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;DB5PR03MB1768;23:4w2eoL1y+RoFWK+Ptt8OH5GjRkoKryh5zfEkvzIC1?= =?us-ascii?Q?wwsVTnGryK/6owz6ilq6o4MNLGP0FUz0PWlaH5M9Nn8PhSJyBO2XsanvFM0c?= =?us-ascii?Q?0kC9SJROM0KWjXXXMahPJ3pQ/VRsA9xhrC1omMvNQPq+2NazAxYj1mOmrjP2?= =?us-ascii?Q?sHo4oRvVs6vLaVgdBzOURURL9y/NGJP/Q500vOkDXIvFYRzrMNMIFVL49ZRP?= =?us-ascii?Q?Rj6Ee8YqiDYoKpCwpCq4Inhe+aVmy6J8cbX0q5EMFLwyD2kNj12gJqQIp5nG?= =?us-ascii?Q?P4KGZMuVhtMVYW4sQ3z8QtcUp2Uadb4FHnKWq15G11G++SSceJSKr8mUbgD3?= =?us-ascii?Q?T7ab4ICXATqkF0+LYL4iAUGch+ggbmQwGnHBlYYqRLsIeRoN5LrcQPetVaSC?= =?us-ascii?Q?L9KKjIvtuTOatCUUOQSTsBdIdD4YxmO/hOGSwm88+e3+9xG7AtN72yz2vEkc?= =?us-ascii?Q?cBFjyYBtFQbUvJcIA6HYzVprBwJ04EDIQL0w3et4Bq/URzT9rR+IjVDN+Lvf?= =?us-ascii?Q?wgzdbSqqC2zU2ni0Mm0Rh9EXmR8tHu2QUKftmf9kaGoamwEBpOR01SwqRz10?= =?us-ascii?Q?oCjIssdeEcvNXsL785apVTUgM3eIY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A4X1yLExxTWbAXyQpA93v403SrZnxj/w+qGXPe6iJY8ja3Pun96KR14V3ZAaUbzNjVyQ76s4hOMQu0DpfWTO5qH8uJG6Ehj7HXLzrBU2KdbmUqDFA2A=;5:Mq8ZkAdfQSA/xL0qE/3X48kmt07olzm0afZjHy11rrLSESbIP3dWxxSaGRijkPvkqaPfaBN7RFPMHQvr6/enSqd7rwT8h1l9AyQlqnQvw0fT4mmjjxkCaAnO+P6e7sI3KRzKBpyxHwR1oa/TqJGP4mtyHpEF2H21hFSdHLug88M=;24:XFkd6hiqe/sr7n+Y+5AzeT7nvRTlzl7+oeOzgvff3Nbyc3DQYePnz3kVLKApiTEKIb4iEFFKWPY4MPUDYO/j7BEV51c2LbGHtzHdP1R/MXA=;7:lZCFOOpNH25XblVW//GMyaT5KSzo4041CrM82P6ZVCjhX/VoDENub3iusmza1cfHLkRC2Bf1KtA3Q0jxnP6/NDfdX2i349IIA38TeFCn1VwtZuGP4mlKDmvrmKmJcGnlisXvSh6aftDy+f+nBIDHo7tfSmEpjHga6UJ1rF11s3Sz3Qrzhh0AfsEWEu2qZJpe3MHt8UPFoxFHOfxAeEpYJpuhWSpI4/I5iTsMPjOd9GyaD5bZZvruWR6efzO8Wltu SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2017 12:48:48.9056 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 493f2267-4855-4236-4acd-08d5372789a9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR03MB1768 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Volodymyr Babchuk Hello all, This is resend of OP-TEE dynamic SHM series. No changes from last time. Correct version is used in the subject. --- Changes from v1: * Added support for 16K and 64K pages. Elaborated commit messages * More minor changes are described in corresponding patches. While this patches are necessary for use OP-TEE in virualized environment, they are not sufficient. Stuart Yoder was right, when proposed to make static SHM optional. But that would be a breaking change, because this will render unusable older client libraries and supplicants. Also, as Mark Rutland pointed, OP-TEE virtualization will need support from hypervisor side. Anyways, those patches allowed me to call OP-TEE from XEN's Dom0 without remapping static SHM region into Dom0 userspace. Also, this patches allow me to share quite big buffers (I tried to use three 2M buffers at a time). This is imposible with static SHM, because static SHM on most platforms is only 2M. Thanks to Yury Norov and Mark Rutland for reviewing this patch series. --- v1 cover letter: This patch series enables dynamic shared memory support in the TEE subsystem as a whole and in OP-TEE in particular. Global Platform TEE specification [1] allows client applications to register part of own memory as a shared buffer between application and TEE. This allows fast zero-copy communication between TEE and REE. But current implementation of TEE in Linux does not support this feature. Also, current implementation of OP-TEE transport uses fixed size pre-shared buffer for all communications with OP-TEE OS. This is okay in the most use cases. But this prevents use of OP-TEE in virtualized environments, because: a) We can't share the same buffer between different virtual machines b) Physically contiguous memory as seen by VM can be non-contiguous in reality (and as seen by OP-TEE OS) due to second stage of MMU translation. c) Size of this pre-shared buffer is limited. So, first part of this patch series adds generic register/unregister interface to tee subsystem. Next patches add necessary features into OP-TEE driver, so it can use not only static pre-shared buffer, but whole RAM to communicate with OP-TEE OS. [1] https://www.globalplatform.org/specificationsdevice.asp Jens Wiklander (2): tee: flexible shared memory pool creation tee: add register user memory Volodymyr Babchuk (12): tee: shm: add accessors for buffer size and page offset tee: shm: add page accessor functions tee: optee: Update protocol definitions tee: optee: add page list manipulation functions tee: optee: add shared buffer registration functions tee: optee: add registered shared parameters handling tee: optee: add registered buffers handling into RPC calls tee: optee: store OP-TEE capabilities in private data tee: optee: add optee-specific shared pool implementation tee: optee: enable dynamic SHM support tee: use reference counting for tee_context tee: shm: inline tee_shm_get_id() drivers/tee/optee/Makefile | 1 + drivers/tee/optee/call.c | 179 +++++++++++++++++++++++++++++- drivers/tee/optee/core.c | 152 +++++++++++++++++++------ drivers/tee/optee/optee_msg.h | 38 ++++++- drivers/tee/optee/optee_private.h | 27 ++++- drivers/tee/optee/optee_smc.h | 7 ++ drivers/tee/optee/rpc.c | 77 +++++++++++-- drivers/tee/optee/shm_pool.c | 75 +++++++++++++ drivers/tee/optee/shm_pool.h | 23 ++++ drivers/tee/tee_core.c | 81 ++++++++++++-- drivers/tee/tee_private.h | 60 +--------- drivers/tee/tee_shm.c | 227 +++++++++++++++++++++++++++++++------- drivers/tee/tee_shm_pool.c | 165 ++++++++++++++++----------- include/linux/tee_drv.h | 183 +++++++++++++++++++++++++++++- include/uapi/linux/tee.h | 30 +++++ 15 files changed, 1104 insertions(+), 221 deletions(-) create mode 100644 drivers/tee/optee/shm_pool.c create mode 100644 drivers/tee/optee/shm_pool.h -- 2.7.4 From 1581172573340295950@xxx Fri Oct 13 19:41:13 +0000 2017 X-GM-THRID: 1579807611018198018 X-Gmail-Labels: Inbox,Category Forums