From patchwork Wed Sep 18 18:50:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 11151155 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB254197C for ; Wed, 18 Sep 2019 18:52:52 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 8657F21A4C for ; Wed, 18 Sep 2019 18:52:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=epam.com header.i=@epam.com header.b="U+2nIVv5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8657F21A4C Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=epam.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAf2X-0006Ar-M8; Wed, 18 Sep 2019 18:50:57 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAf2W-0006AX-AX for xen-devel@lists.xenproject.org; Wed, 18 Sep 2019 18:50:56 +0000 X-Inumbo-ID: 3d4d380a-da45-11e9-978d-bc764e2007e4 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (unknown [2a01:111:f400:fe0e::610]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3d4d380a-da45-11e9-978d-bc764e2007e4; Wed, 18 Sep 2019 18:50:53 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JMU04dRMAPlzKMH4aCsDTRY8I4tpVYPsFhD7AVURhKKoheCd+THzPpBxHCcjKLjdUMvJm38y9XC60V64ntzhCgJzM0jjF0iI6IeLR/47g+gVEup5v/4y+fcha8y518R0c407LFpI41j//4LraLC0QDVOVJE+N618jFNw4Cx7J0RFXdHpqbnR7ZM9utdMfco0MC5pnJ1gZSE2MOSuNPzL95QshtpPGMJcFOK7IDR7nDp9cTpZ14LqO+4FS2RjHazr7YryD+A5CvIGZempKgmNqjeKC4lBOp3scdeJQGNjLg/nkryJ7mPwmDk+Z5g8G/D/rw19oWZSTfVIEmRPsog22A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BO64aWIMKF8+kHI1j+d2aul1S4f+TxtzxSQwzpb1xk4=; b=Qu1L1tZHK7SR16Ky4ETs8a52dpEHbr2zCb/zqifmTPmuSXvwLeV0lX3CasXtiYwqz2R984jGOXhTiN4gFXS2RmwbrE6jtr56n1RLqdYAC8FvTnjaRNcCGVupHc9gsNmAXtkRMPV9ijtTEy8UN7TFYgyh76jaiuSfIpxRvE5eOsymSxRLg7DqTYZgcDRr9y9Ov+0E2Whp/YJg2SqdBTtIpNuw+K4XiE4fYYSibrRjfpKDRhF7ObhsgPVxYvv100LGKQyYT7eeRNFBVxyUr4pFbsweX6l073T0RFydpIFuCP7zZwmJfDi3bcq3ekTP4+F2BpsOWSb792oa5F4xfuLerg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BO64aWIMKF8+kHI1j+d2aul1S4f+TxtzxSQwzpb1xk4=; b=U+2nIVv5YeOqt9N4jBHaKdmh04m+Fx18tKSzyo0GBQxGsINn9h/sKHPaso/mxriMMwmQwaA78s2jnErFNPSI3illzbBj1LOTlAns13rtp2g5J341R8XPKODRoCXowHyhRvQnK3NkHZ5YY0PplgLHfyVaGGNwW0k/QfZY3zn5YEY= Received: from AM0PR03MB4148.eurprd03.prod.outlook.com (20.177.40.10) by AM0PR03MB5761.eurprd03.prod.outlook.com (20.179.252.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.15; Wed, 18 Sep 2019 18:50:51 +0000 Received: from AM0PR03MB4148.eurprd03.prod.outlook.com ([fe80::71e3:834d:5708:5a0a]) by AM0PR03MB4148.eurprd03.prod.outlook.com ([fe80::71e3:834d:5708:5a0a%5]) with mapi id 15.20.2199.015; Wed, 18 Sep 2019 18:50:51 +0000 From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH v2 1/6] xen/arm: optee: impose limit on shared buffer size Thread-Index: AQHVblH+avUrsKasKUuqntnk7iOMNA== Date: Wed, 18 Sep 2019 18:50:51 +0000 Message-ID: <20190918185041.22738-2-volodymyr_babchuk@epam.com> References: <20190918185041.22738-1-volodymyr_babchuk@epam.com> In-Reply-To: <20190918185041.22738-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Volodymyr_Babchuk@epam.com; x-originating-ip: [85.223.209.22] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a723deed-fbb3-4439-d738-08d73c692104 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:AM0PR03MB5761; x-ms-traffictypediagnostic: AM0PR03MB5761:|AM0PR03MB5761: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(376002)(39860400002)(346002)(396003)(189003)(199004)(52084003)(66476007)(6116002)(478600001)(14454004)(66446008)(80792005)(2616005)(55236004)(8936002)(66066001)(5660300002)(2501003)(81156014)(305945005)(7736002)(81166006)(66556008)(8676002)(256004)(71200400001)(14444005)(71190400001)(99286004)(54906003)(1076003)(86362001)(26005)(11346002)(6512007)(5640700003)(2906002)(186003)(102836004)(3846002)(64756008)(76116006)(2351001)(91956017)(6506007)(25786009)(486006)(66946007)(36756003)(476003)(446003)(4326008)(316002)(6436002)(76176011)(6486002)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR03MB5761; H:AM0PR03MB4148.eurprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: epam.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: TOElGEeH6956ADnV/Kzf8VC1K2e5FfCBcwKmcKX91XCBVin5zhth/NgQT7dRJc2TGvo93Ez3QYkcyE1pI9p7K3GAd5kQQMSLzrz2+zUSl8L13+jb+uP/lsv7ese/sDoGEZksSiU2D6Nz1dU0hO3nvQ2y92NqXiF/AKV4Mf4ojbqbsy8/JDysCz8093+VXDFjGJDX3peN7qRG4I75tM6NAnjYfndqTtJTPJ4WhxA855dKrKFK3bdFXGKxggM1izlmsAWvrYbCoX60VQjmvuTXH6vaRptwtAG9t1J30e33nXFgbpHZ0HzHmSQQbW1EZYmLK9dALCOBZxevPMgXH+kHY5AZOAhorGf500X1Sq3XmoNZAOzX5EaOYsiWun19/55y/I3XVwL1CT5bMb77K7ATu/0MZi5xtrQD2XkZLNmKjzg= MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-Network-Message-Id: a723deed-fbb3-4439-d738-08d73c692104 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 18:50:51.7463 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 1J7LHiSkQC3hGzvqds2x4L+lZTDBbKPL6n9OLIBxmjBEZK9XiTk9RmUQYF5es39SvYrsZ73tg9oHs7FwjYAORWStuVvWVqqslLmRqraMO4M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR03MB5761 Subject: [Xen-devel] [PATCH v2 1/6] xen/arm: optee: impose limit on shared buffer size X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: "tee-dev@lists.linaro.org" , Julien Grall , Stefano Stabellini , Volodymyr Babchuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" We want to limit number of calls to lookup_and_pin_guest_ram_addr() per one request. There are two ways to do this: either preempt translate_noncontig() or limit size of one shared buffer size. It is quite hard to preempt translate_noncontig(), because it is deep nested. So we chose the second option. We will allow 129 pages per one shared buffer. This corresponds to the GP standard, as it requires that size limit for shared buffer should be at least 512kB. One extra page (129th) is needed to cope with the fact that user's buffer is not necessary aligned with page boundary. Also, with this limitation OP-TEE still passes own "xtest" test suite, so this is okay for now. Signed-off-by: Volodymyr Babchuk --- Changes from v1: - Added comment before BUILD_BUG_ON(PAGE_SIZE != 4096); - Fixed typo in the commit message - Decreased MAX_SHM_BUFFER_PG to 129 --- xen/arch/arm/tee/optee.c | 44 +++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c index ec5402e89b..d64e9c3b85 100644 --- a/xen/arch/arm/tee/optee.c +++ b/xen/arch/arm/tee/optee.c @@ -72,6 +72,19 @@ */ #define MAX_TOTAL_SMH_BUF_PG 16384 +/* + * Limit for shared buffer size. Please note that this define limits + * number of pages. But user buffer can be not aligned to a page + * boundary. So it is possible that user would not be able to share + * exactly MAX_SHM_BUFFER_PG * PAGE_SIZE bytes with OP-TEE. + * + * Global Platform specification for TEE requires that any TEE + * implementation should allow to share buffers with size of at least + * 512KB, which equals to 128 4KB pages. Due to align issue mentioned + * above, we need to increase this value to 129. + */ +#define MAX_SHM_BUFFER_PG 129 + #define OPTEE_KNOWN_NSEC_CAPS OPTEE_SMC_NSEC_CAP_UNIPROCESSOR #define OPTEE_KNOWN_SEC_CAPS (OPTEE_SMC_SEC_CAP_HAVE_RESERVED_SHM | \ OPTEE_SMC_SEC_CAP_UNREGISTERED_SHM | \ @@ -697,16 +710,29 @@ static int translate_noncontig(struct optee_domain *ctx, size = ROUNDUP(param->u.tmem.size + offset, OPTEE_MSG_NONCONTIG_PAGE_SIZE); pg_count = DIV_ROUND_UP(size, OPTEE_MSG_NONCONTIG_PAGE_SIZE); + if ( pg_count > MAX_SHM_BUFFER_PG ) + return -ENOMEM; + order = get_order_from_bytes(get_pages_list_size(pg_count)); /* - * In the worst case we will want to allocate 33 pages, which is - * MAX_TOTAL_SMH_BUF_PG/511 rounded up. This gives order 6 or at - * most 64 pages allocated. This buffer will be freed right after - * the end of the call and there can be no more than + * In the worst case we will want to allocate 1 page, which is + * MAX_SHM_BUFFER_PG/511 rounded up. This buffer will be freed + * right after the end of the call and there can be no more than * max_optee_threads calls simultaneously. So in the worst case - * guest can trick us to allocate 64 * max_optee_threads pages in + * guest can trick us to allocate 1 * max_optee_threads pages in * total. + * + * It may seem strange to have such complex calculations if we + * always will allocate exactly one page. Those calculations exist + * in the first place because earlier there were bigger limit for + * shared buffer size, so there were cases, when we needed more + * that one page there. Right now this is not true, but this code + * remains for two reasons: + * - Users can change MAX_SHM_BUFFER_PG to a higher value, in which + * case they will need this code. + * - There is a plan to implement preemption in the code below, which + * will allow use to increase default MAX_SHM_BUFFER_PG value. */ xen_pgs = alloc_domheap_pages(current->domain, order, 0); if ( !xen_pgs ) @@ -747,13 +773,7 @@ static int translate_noncontig(struct optee_domain *ctx, xen_data = __map_domain_page(xen_pgs); } - /* - * TODO: That function can pin up to 64MB of guest memory by - * calling lookup_and_pin_guest_ram_addr() 16384 times - * (assuming that PAGE_SIZE equals to 4096). - * This should be addressed before declaring OP-TEE security - * supported. - */ + /* Only 4k pages are supported right now */ BUILD_BUG_ON(PAGE_SIZE != 4096); page = get_domain_ram_page(gaddr_to_gfn(guest_data->pages_list[idx])); if ( !page ) From patchwork Wed Sep 18 18:50:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 11151147 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 193AA1745 for ; Wed, 18 Sep 2019 18:52:19 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 E8BEC21BE5 for ; Wed, 18 Sep 2019 18:52:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=epam.com header.i=@epam.com header.b="kUNJy8pj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8BEC21BE5 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=epam.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAf2d-0006D5-0D; Wed, 18 Sep 2019 18:51:03 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAf2b-0006Bs-9k for xen-devel@lists.xenproject.org; Wed, 18 Sep 2019 18:51:01 +0000 X-Inumbo-ID: 400037b4-da45-11e9-b299-bc764e2007e4 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (unknown [2a01:111:f400:fe0e::61c]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 400037b4-da45-11e9-b299-bc764e2007e4; Wed, 18 Sep 2019 18:50:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RLa/pWlBl5eHyJPHOizEjb6edtJI48jRE9w6GHlsTzJ7tG9txafUUS/u3i94E1R1E7iInD8/JYZ+Z2zWI8c7aAvXF772t2PZDQU0TZFDFoMVxqXh+VxEW8v7OpzdRtwIcq9HVglDtqWEl7VPjjNeOHuD5bTRFYWJntDPyfFjjRPVA7qrRhZ4R7sIOkMwuEvYUot/sqx4pOe055OL5KvWG6t5ssVSs5sLfwRVFz9OJFRw7mHgRJ4hQO5AugijZUdztx72TFQdM32rHz46Vh5FVn5KYz8KacdrYdZHps4EPC3hVJ2/20er4akXb9AQlSoovK+hfdd5YqDLldRQzynYYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AqXfQOLOnYJoNe5kfocRbeNB6ZWU3b9htobggzv1TZU=; b=DEUTSdcN2Ffyv8+i9or8GgLdxL8o8D6u2OYdu40zMJDW37Y57dP8sQuJ2Sd0m4+EtpOJ+Bekn1j4IzPMb48RCW6n81FbSkXuLD0B2J1qscXG6JJ3+My8wx/bcU0WdzAJ9wH6Hvh7slsKYPnMpegQJTzAYE5ANXLwH3hTKnRBKXyjypjgxBi+LiSVbjw4Vvm/CU4CaiTnPYyhV0DMXd2LGOexmAK4cxRI/bNU5ZGgB6NL7M3FwpoJKpKMtHxlu+l5Ndr9FFMqg5eduGaMf/+RYErfObqs1L1eCaF9eA2iU1rfGJIBMQpFYI4UTcO0jAufooKPT44qbJTZIqTLlXl9bg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AqXfQOLOnYJoNe5kfocRbeNB6ZWU3b9htobggzv1TZU=; b=kUNJy8pjkhIZyh8SqDADX0ZXTFuh/1QqOrnC+9YCZlfL+el0E9rQR8V6OKCGNo9hKQMHVuuyXqiWoztSeQuLDgH1NX8IPmvJxcw8VYxroQWMYY4zpsmuJlDYhjpuoezPsIZ/ZH7O6DksKLrKxpLP8Kev3Jpe9AhoQxeOmf2F4W0= Received: from AM0PR03MB4148.eurprd03.prod.outlook.com (20.177.40.10) by AM0PR03MB5761.eurprd03.prod.outlook.com (20.179.252.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.15; Wed, 18 Sep 2019 18:50:56 +0000 Received: from AM0PR03MB4148.eurprd03.prod.outlook.com ([fe80::71e3:834d:5708:5a0a]) by AM0PR03MB4148.eurprd03.prod.outlook.com ([fe80::71e3:834d:5708:5a0a%5]) with mapi id 15.20.2199.015; Wed, 18 Sep 2019 18:50:56 +0000 From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH v2 2/6] xen/arm: optee: check for preemption while freeing shared buffers Thread-Index: AQHVblIBa+Rcg914Z0Sq56RvzPPcmg== Date: Wed, 18 Sep 2019 18:50:56 +0000 Message-ID: <20190918185041.22738-3-volodymyr_babchuk@epam.com> References: <20190918185041.22738-1-volodymyr_babchuk@epam.com> In-Reply-To: <20190918185041.22738-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Volodymyr_Babchuk@epam.com; x-originating-ip: [85.223.209.22] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: bea227ee-2905-48b5-058e-08d73c6923c4 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:AM0PR03MB5761; x-ms-traffictypediagnostic: AM0PR03MB5761:|AM0PR03MB5761: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1169; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(376002)(39860400002)(346002)(396003)(189003)(199004)(66476007)(6116002)(478600001)(14454004)(66446008)(80792005)(2616005)(55236004)(8936002)(66066001)(5660300002)(2501003)(81156014)(305945005)(7736002)(81166006)(66556008)(8676002)(256004)(71200400001)(71190400001)(99286004)(54906003)(1076003)(86362001)(26005)(11346002)(6512007)(5640700003)(2906002)(186003)(102836004)(3846002)(64756008)(76116006)(2351001)(91956017)(6506007)(25786009)(486006)(66946007)(36756003)(476003)(446003)(4326008)(316002)(6436002)(76176011)(6486002)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR03MB5761; H:AM0PR03MB4148.eurprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: epam.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Kz5akGMxrIP6eRoyC5tzZaQguCz3ll01D/SvTGMk/vcu50DPrI661HIRDornWH+YpsnIdvQZoKGIyTs/I00WS2foSgHKuhDJpDNHMK9I6eE20/LWl+rZEt7n+rbUxdiHdtcrZLFkntcve9zmWf51408a1u6UaBHRDZlVm1o2LzMtomE8J6FQ+OcLNYgxwIO8yCdw4G1WzWp2pxT4jlTQhADQn+7H7eBt1GRzBSw6c5a4xRlO/HiqMLu3R/OkcJWDhMVyMoTGvH0gXR7uj33TMX0p5JRBkik3uCr6PyYBAWPNlsXy7rbiVLwPuq1rDXO60C7zL7ku6bLlmQOKKmr+VTjff7jSjmvwg9QMl80xqN+a+ZWrZoeuAT8MWrYuCYUlMtrDIRcjUb92CqPsD3mKHbF9t+orIZBlbEkYq1CiQmQ= MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-Network-Message-Id: bea227ee-2905-48b5-058e-08d73c6923c4 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 18:50:56.4616 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: BD9Pj96b+82t6bBwaPY0NqUkrCp9++LIEMT3+HgSREFwSMTVUA52MPNze1MCIvNhrbglHKAs/mYi82c1q9W2RkSMGnAYTM9zzxSSKDmCDLg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR03MB5761 Subject: [Xen-devel] [PATCH v2 2/6] xen/arm: optee: check for preemption while freeing shared buffers X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: "tee-dev@lists.linaro.org" , Julien Grall , Stefano Stabellini , Volodymyr Babchuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" We can check for hypercall_preempt_check() in the loop inside optee_relinquish_resources() to increase hypervisor responsiveness in case if preemption is required. Signed-off-by: Volodymyr Babchuk Acked-by: Julien Grall --- Changes from v1: - Removed extra hypercall_preempt_check() - Updated the commit message --- xen/arch/arm/tee/optee.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c index d64e9c3b85..55d11b91a9 100644 --- a/xen/arch/arm/tee/optee.c +++ b/xen/arch/arm/tee/optee.c @@ -633,17 +633,14 @@ static int optee_relinquish_resources(struct domain *d) list_for_each_entry_safe( shm_rpc, shm_rpc_tmp, &ctx->shm_rpc_list, list ) free_shm_rpc(ctx, shm_rpc->cookie); - if ( hypercall_preempt_check() ) - return -ERESTART; - - /* - * TODO: Guest can pin up to MAX_TOTAL_SMH_BUF_PG pages and all of - * them will be put in this loop. It is worth considering to - * check for preemption inside the loop. - */ list_for_each_entry_safe( optee_shm_buf, optee_shm_buf_tmp, &ctx->optee_shm_buf_list, list ) + { + if ( hypercall_preempt_check() ) + return -ERESTART; + free_optee_shm_buf(ctx, optee_shm_buf->cookie); + } if ( hypercall_preempt_check() ) return -ERESTART; From patchwork Wed Sep 18 18:50:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 11151153 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D9D8112B for ; Wed, 18 Sep 2019 18:52:52 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 7887621928 for ; Wed, 18 Sep 2019 18:52:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=epam.com header.i=@epam.com header.b="KgOxQfIt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7887621928 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=epam.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAf2h-0006FL-A7; Wed, 18 Sep 2019 18:51:07 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAf2g-0006Ei-B4 for xen-devel@lists.xenproject.org; Wed, 18 Sep 2019 18:51:06 +0000 X-Inumbo-ID: 420acab0-da45-11e9-b299-bc764e2007e4 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (unknown [40.107.8.44]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 420acab0-da45-11e9-b299-bc764e2007e4; Wed, 18 Sep 2019 18:51:01 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Subn5MWVhJx2Et1EY6/pNkASkvAp6aA5cHxTpAc802c9YZu4yloDZKddIbRtcnYLW78vO3qqj1jMYZ3s6qXvUvugqgE1cM81SvyYCOjaXHuKJq9C1ZM2J2GsxugDACgktkuJKRKEmj9iVjSvvEaduM4gqbSDRNWkeTBqelvL8/cKkdRhUvWAJRK18kMH7YzAtGutfHNJ32pGMrBCt1FmqQaoCM8i2aE7DZYvjrkajF1iD5Zc7NfaNFtrFJ7npFm8INDu2VM96t6FPbgD4kUuGId/vzomFL1YHnQ8QkskPnk87KRqcIEDanLN/RIyYhpI+olIvpQz5dpgWRjKt7TFrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bUVUVQgeO7ZQc9FMlIXiSEBIkKIp00y6FcNfsfQE1+4=; b=NS1zG8GOyhlD7IPiBRF6NrQfwQPheY1Faf4o+6yON4IqVX15vUwPKjXv2+3iDjzY9c2hnpKzezqNwWgpQ4WT0nxaeA0Qpf1uI4l1Hv2/utLnZua42wKRkTyy0HPQFZO4TRNC0vWgbK2r8hzKmVpCXnwT4gW8yPlXXJKnadSkPN7IVvg5MicxEOF2kDwKHSXzI1ced8SAGHTJqijDpefZLgYFPulalllLYouQxjEmsa2uaVz+T9y4e11id2yq3qwkU/dki5Gk5RMcGYH8ce9MmOc/OKb4QlpbkY0rw2+yoyOLohHgZPegCd1KCgtVh87x6WdI8fzAP8TI3+uQlCUDvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bUVUVQgeO7ZQc9FMlIXiSEBIkKIp00y6FcNfsfQE1+4=; b=KgOxQfItDzN+48PEstO63k9c8VW/sDK4ZSvEjOWmmQkSPGJHBZvvqOnM5j1fbzqWLCFfDyjYD6mzWx4oiE1cGNZ5SLI6yxNP0DHWrNgykyj+YmusBaE7ZpZNoAYfKUP3izqD0vUocIhgyInXyrBTFncn3uw9KJ2KsMMzDzQy7aU= Received: from AM0PR03MB4148.eurprd03.prod.outlook.com (20.177.40.10) by AM0PR03MB5761.eurprd03.prod.outlook.com (20.179.252.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.15; Wed, 18 Sep 2019 18:50:59 +0000 Received: from AM0PR03MB4148.eurprd03.prod.outlook.com ([fe80::71e3:834d:5708:5a0a]) by AM0PR03MB4148.eurprd03.prod.outlook.com ([fe80::71e3:834d:5708:5a0a%5]) with mapi id 15.20.2199.015; Wed, 18 Sep 2019 18:50:59 +0000 From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH v2 3/6] xen/arm: optee: limit number of shared buffers Thread-Index: AQHVblIDOzQYaSMlIUe2FmdIoibUfw== Date: Wed, 18 Sep 2019 18:50:59 +0000 Message-ID: <20190918185041.22738-4-volodymyr_babchuk@epam.com> References: <20190918185041.22738-1-volodymyr_babchuk@epam.com> In-Reply-To: <20190918185041.22738-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Volodymyr_Babchuk@epam.com; x-originating-ip: [85.223.209.22] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 918fd33c-f5ac-46b1-56e1-08d73c6925c5 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:AM0PR03MB5761; x-ms-traffictypediagnostic: AM0PR03MB5761:|AM0PR03MB5761: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4941; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(376002)(39860400002)(346002)(396003)(189003)(199004)(66476007)(6116002)(478600001)(14454004)(66446008)(80792005)(2616005)(55236004)(8936002)(66066001)(5660300002)(2501003)(81156014)(305945005)(7736002)(81166006)(66556008)(8676002)(256004)(71200400001)(14444005)(71190400001)(99286004)(54906003)(1076003)(86362001)(26005)(11346002)(6512007)(5640700003)(2906002)(186003)(102836004)(3846002)(64756008)(76116006)(2351001)(91956017)(6506007)(25786009)(486006)(66946007)(36756003)(476003)(446003)(4326008)(316002)(6436002)(76176011)(6486002)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR03MB5761; H:AM0PR03MB4148.eurprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: epam.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: rRafnntzk6X0AOCyt2y+Ur1w7X3Y4wvroGDtlJGVSjsgWRVCqN5ipIO+VK9uxgoX7ttpPQslSBtT49yeHGiAkVQ2QJh/8luIlO2aXOMeZ1Iy+nZfMfwFbxStUits4tCHsICX/2n7MhCdf+Z65lKazMTNo5+3FfjkcreSOIM1Rm3oqoPvHrgNpB6BG1mjPl7bj2WxA2H70AqGIaubcXKukzuzV+TNFtDcibZon2FGVIuOc989NjNFQVC0NXpfq3rHVqDqtlzoMWyf90CotMPTs7zueSGzIdJXEIWKgn3e27t4QBjhS8tDULP3jsYV/x6bNyMVjOU7b1jKInDdq6qnqRuOSd/9c/se1M661bZzJPPWbJ+z6JI62EsH8Nl4H7xcWEUtPZaUl38zVgsv5lysvyyKKaShGSXc5kpwPSexPd8= MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-Network-Message-Id: 918fd33c-f5ac-46b1-56e1-08d73c6925c5 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 18:50:59.7997 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 64T5AuvTw/amivovMkU18/GJU7J1yOO+YmvocejgkCfNoOvTIuSJBy5kGQV/KVm1UCgl8PuwmPEnqZwBbemfG1EkHIhW1E62xO6n77OZvA0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR03MB5761 Subject: [Xen-devel] [PATCH v2 3/6] xen/arm: optee: limit number of shared buffers X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: "tee-dev@lists.linaro.org" , Julien Grall , Stefano Stabellini , Volodymyr Babchuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" We want to limit number of shared buffers that guest can register in OP-TEE. Every such buffer consumes XEN resources and we don't want guest to exhaust XEN. So we choose arbitrary limit for shared buffers. Signed-off-by: Volodymyr Babchuk Acked-by: Julien Grall --- xen/arch/arm/tee/optee.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c index 55d11b91a9..88be959819 100644 --- a/xen/arch/arm/tee/optee.c +++ b/xen/arch/arm/tee/optee.c @@ -85,6 +85,14 @@ */ #define MAX_SHM_BUFFER_PG 129 +/* + * Limits the number of shared buffers that guest can have at once. + * This is to prevent case, when guests tricks XEN into exhausting + * own memory by allocating zillions of one-byte buffers. Value is + * chosen arbitrary. + */ +#define MAX_SHM_BUFFER_COUNT 16 + #define OPTEE_KNOWN_NSEC_CAPS OPTEE_SMC_NSEC_CAP_UNIPROCESSOR #define OPTEE_KNOWN_SEC_CAPS (OPTEE_SMC_SEC_CAP_HAVE_RESERVED_SHM | \ OPTEE_SMC_SEC_CAP_UNREGISTERED_SHM | \ @@ -146,6 +154,7 @@ struct optee_domain { struct list_head optee_shm_buf_list; atomic_t call_count; atomic_t optee_shm_buf_pages; + atomic_t optee_shm_buf_count; spinlock_t lock; }; @@ -233,6 +242,7 @@ static int optee_domain_init(struct domain *d) INIT_LIST_HEAD(&ctx->optee_shm_buf_list); atomic_set(&ctx->call_count, 0); atomic_set(&ctx->optee_shm_buf_pages, 0); + atomic_set(&ctx->optee_shm_buf_count, 0); spin_lock_init(&ctx->lock); d->arch.tee = ctx; @@ -481,23 +491,26 @@ static struct optee_shm_buf *allocate_optee_shm_buf(struct optee_domain *ctx, struct optee_shm_buf *optee_shm_buf, *optee_shm_buf_tmp; int old, new; int err_code; + int count; + + count = atomic_add_unless(&ctx->optee_shm_buf_count, 1, + MAX_SHM_BUFFER_COUNT); + if ( count == MAX_SHM_BUFFER_COUNT ) + return ERR_PTR(-ENOMEM); do { old = atomic_read(&ctx->optee_shm_buf_pages); new = old + pages_cnt; if ( new >= MAX_TOTAL_SMH_BUF_PG ) - return ERR_PTR(-ENOMEM); + { + err_code = -ENOMEM; + goto err_dec_cnt; + } } while ( unlikely(old != atomic_cmpxchg(&ctx->optee_shm_buf_pages, old, new)) ); - /* - * TODO: Guest can try to register many small buffers, thus, forcing - * XEN to allocate context for every buffer. Probably we need to - * limit not only total number of pages pinned but also number - * of buffer objects. - */ optee_shm_buf = xzalloc_bytes(sizeof(struct optee_shm_buf) + pages_cnt * sizeof(struct page *)); if ( !optee_shm_buf ) @@ -533,6 +546,8 @@ static struct optee_shm_buf *allocate_optee_shm_buf(struct optee_domain *ctx, err: xfree(optee_shm_buf); atomic_sub(pages_cnt, &ctx->optee_shm_buf_pages); +err_dec_cnt: + atomic_dec(&ctx->optee_shm_buf_count); return ERR_PTR(err_code); } @@ -575,6 +590,7 @@ static void free_optee_shm_buf(struct optee_domain *ctx, uint64_t cookie) free_pg_list(optee_shm_buf); atomic_sub(optee_shm_buf->page_cnt, &ctx->optee_shm_buf_pages); + atomic_dec(&ctx->optee_shm_buf_count); xfree(optee_shm_buf); } From patchwork Wed Sep 18 18:51:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 11151149 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 42EB0112B for ; Wed, 18 Sep 2019 18:52:25 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 1269121928 for ; Wed, 18 Sep 2019 18:52:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=epam.com header.i=@epam.com header.b="s/zUTAzP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1269121928 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=epam.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAf2m-0006IT-Lp; Wed, 18 Sep 2019 18:51:12 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAf2l-0006Hs-AU for xen-devel@lists.xenproject.org; Wed, 18 Sep 2019 18:51:11 +0000 X-Inumbo-ID: 43de519a-da45-11e9-a337-bc764e2007e4 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (unknown [40.107.8.43]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 43de519a-da45-11e9-a337-bc764e2007e4; Wed, 18 Sep 2019 18:51:04 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gbZAwUMZdhftgAC/9AtTZZB5zkkY3SlZNrwjJB/lWetgObRkirHuyAqmBToAiJvZVujqpczjJ1khltmJ1NUVfka4Q/IO72V/G1EBHVAhszWgWmztB+tS36PbJ4o8hvZKBwHfCNRPXaDintHvGhLpkDYX/9dYSv0cTWrUpbuAHwNV7FvcJQawfnIBrmGGr2BQ23juZQSj14cZ1ztPs/AVvTpkGbHhNefeXjfzv5EvSr0wjRcLNTGeK4kbxwjmI3qr5D2NJ0T6OqDC5tVx+Bun9lueOMzOQ9qS6eRVbcrDKeF8hcW8Ew0Kvel6UUDKm5WSv+L42PU2pH29ANBxDquR/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pjsT0snnco0gXPBDeF57uLeR/PMguD4mh0/rGAvu1yc=; b=oDOu8Cq7ZU3EZbzpX/xjpmsoblgz+UeRpKcB4X8Q92rouZb8Mjn6fPMO4fAh+OwvTm074Mg0a0iTaT+nRRKMbKXNArftUN39WIwY6r+gP/dArXJXk1QcixzVZ01l0AJ9JXRtsT9Nu+5G3DJtuGK3LNeIeZ27H9pZGnJAYY+62YT6hbHgf5urhfiu35RyqMRWkEZB7Lfqsg/HkB/KVBA8cnumf8ppGrzEOUhSdkxhL3YPY1KSh+B06GF6C2r5X5MZFfBJ+OayIMYdDyACUesjCKVqCLX12bdLeB3Zx3bDGfNvV6OrBIPAmC0KdtC2joWbrsFHtEPVDiMVT5mTkmYNDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pjsT0snnco0gXPBDeF57uLeR/PMguD4mh0/rGAvu1yc=; b=s/zUTAzP06Fs9754xe4heu8RHccEbFBSnwyc0ZueR1DH4j6q+Lzi323yNNsdgh4zqHAa8h6l1zLtiLEKEMME0xCjNLZNeZOe5EIKtlXz0vtCQrG2ZTtH/2Y7rFKrSHLyVA16AfHajgnG9u0m7rZ7h48avnt4N5bROwOAJFXKI7s= Received: from AM0PR03MB4148.eurprd03.prod.outlook.com (20.177.40.10) by AM0PR03MB5761.eurprd03.prod.outlook.com (20.179.252.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.15; Wed, 18 Sep 2019 18:51:03 +0000 Received: from AM0PR03MB4148.eurprd03.prod.outlook.com ([fe80::71e3:834d:5708:5a0a]) by AM0PR03MB4148.eurprd03.prod.outlook.com ([fe80::71e3:834d:5708:5a0a%5]) with mapi id 15.20.2199.015; Wed, 18 Sep 2019 18:51:02 +0000 From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH v2 4/6] xen/arm: optee: handle shared buffer translation error Thread-Index: AQHVblIEDLSpGG3MwUmqKYBWTkOKGw== Date: Wed, 18 Sep 2019 18:51:02 +0000 Message-ID: <20190918185041.22738-5-volodymyr_babchuk@epam.com> References: <20190918185041.22738-1-volodymyr_babchuk@epam.com> In-Reply-To: <20190918185041.22738-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Volodymyr_Babchuk@epam.com; x-originating-ip: [85.223.209.22] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 95ae7685-a35b-4ed6-0f29-08d73c692799 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:AM0PR03MB5761; x-ms-traffictypediagnostic: AM0PR03MB5761:|AM0PR03MB5761: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(376002)(39860400002)(346002)(396003)(189003)(51234002)(199004)(66476007)(6116002)(478600001)(14454004)(66446008)(80792005)(2616005)(55236004)(8936002)(66066001)(5660300002)(2501003)(81156014)(305945005)(7736002)(81166006)(66556008)(8676002)(256004)(71200400001)(14444005)(71190400001)(99286004)(54906003)(1076003)(86362001)(26005)(11346002)(6512007)(5640700003)(2906002)(186003)(102836004)(3846002)(64756008)(76116006)(2351001)(91956017)(6506007)(25786009)(486006)(66946007)(36756003)(476003)(446003)(4326008)(316002)(6436002)(76176011)(6486002)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR03MB5761; H:AM0PR03MB4148.eurprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: epam.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Ynt4z/dMU2Lp6v43nTdlMnmiCPi0UJJZlBG4U4jbvxBnflH/V4MGcyeW4V7IjvjR+hGD5KUtwR4QfTjcfhPVrYeN/MFNz36uparTK8/ZUutlzhtXiwvjBVZp9+iIU8CFhuOFmVDyVw78oIJBYwiBMndRrLVsvshyPbXNWKQsNIaocvlIpXRBOIvsdKuSU86j+o5o4fT0vkP1HzSBGBNayrBlwKLYEWFqfKFo6OZlVLGFkdfWYd0lIyGfaBHCmoMR+CHpo3TVyMhYhnoEP/L7943MyUqgjHJCVoZ6lwD6yJUKQ8Oo9nWQ+B/SGKJio0Akqs6OpuOn68DaHQLW9XkjWFHI02+MG48G+tfKaSnnf+y4kglVvkj6kGHafF9MOVfeHimUThFYaqfbiogWMUT5DuUIyNbHZCKGHN2+rEZ/ZEM= MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95ae7685-a35b-4ed6-0f29-08d73c692799 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 18:51:02.7880 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: uCK97fWKYjcvHN5Q0Ve6iXJIKaDKKgDNksefi6ro19oHYPehBFJSiLDcP980tVo/HtxsYnjJCx7HnxVWsjGb0v/LvjM97OVDy9gQLasG0Xw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR03MB5761 Subject: [Xen-devel] [PATCH v2 4/6] xen/arm: optee: handle shared buffer translation error X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: "tee-dev@lists.linaro.org" , Julien Grall , Stefano Stabellini , Volodymyr Babchuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" There is a case possible, when OP-TEE asks guest to allocate shared buffer, but Xen for some reason can't translate buffer's addresses. In this situation we should do two things: 1. Tell guest to free allocated buffer, so there will be no memory leak for guest. 2. Tell OP-TEE that buffer allocation failed. To ask guest to free allocated buffer we should perform the same thing, as OP-TEE does - issue RPC request. This is done by filling request buffer (luckily we can reuse the same buffer, that OP-TEE used to issue original request) and then return to guest with special return code. Then we need to handle next call from guest in a special way: as RPC was issued by Xen, not by OP-TEE, it should be handled by Xen. Basically, this is the mechanism to preempt OP-TEE mediator. The same mechanism can be used in the future to preempt mediator during translation large (>512 pages) shared buffers. Signed-off-by: Volodymyr Babchuk --- Changes from v1: - Renamed OPTEEM_CALL_* to OPTEE_CALL_* - Fixed comments - Added ASSERT() in handle_xen_rpc_return() --- xen/arch/arm/tee/optee.c | 172 ++++++++++++++++++++++++++++++++------- 1 file changed, 141 insertions(+), 31 deletions(-) diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c index 88be959819..0a3205f9e8 100644 --- a/xen/arch/arm/tee/optee.c +++ b/xen/arch/arm/tee/optee.c @@ -98,6 +98,11 @@ OPTEE_SMC_SEC_CAP_UNREGISTERED_SHM | \ OPTEE_SMC_SEC_CAP_DYNAMIC_SHM) +enum optee_call_state { + OPTEE_CALL_NORMAL, + OPTEE_CALL_XEN_RPC, +}; + static unsigned int __read_mostly max_optee_threads; /* @@ -114,6 +119,9 @@ struct optee_std_call { paddr_t guest_arg_ipa; int optee_thread_id; int rpc_op; + /* Saved buffer type for the current buffer allocate request */ + unsigned int rpc_buffer_type; + enum optee_call_state state; uint64_t rpc_data_cookie; bool in_flight; register_t rpc_params[2]; @@ -301,6 +309,7 @@ static struct optee_std_call *allocate_std_call(struct optee_domain *ctx) call->optee_thread_id = -1; call->in_flight = true; + call->state = OPTEE_CALL_NORMAL; spin_lock(&ctx->lock); list_add_tail(&call->list, &ctx->call_list); @@ -1086,6 +1095,10 @@ static int handle_rpc_return(struct optee_domain *ctx, ret = -ERESTART; } + /* Save the buffer type in case we will want to free it */ + if ( shm_rpc->xen_arg->cmd == OPTEE_RPC_CMD_SHM_ALLOC ) + call->rpc_buffer_type = shm_rpc->xen_arg->params[0].u.value.a; + unmap_domain_page(shm_rpc->xen_arg); } @@ -1250,18 +1263,107 @@ err: return; } +/* + * Prepare RPC request to free shared buffer in the same way, as + * OP-TEE does this. + * + * Return values: + * true - successfully prepared RPC request + * false - there was an error + */ +static bool issue_rpc_cmd_free(struct optee_domain *ctx, + struct cpu_user_regs *regs, + struct optee_std_call *call, + struct shm_rpc *shm_rpc, + uint64_t cookie) +{ + register_t r1, r2; + + /* In case if guest will forget to update it with meaningful value */ + shm_rpc->xen_arg->ret = TEEC_ERROR_GENERIC; + shm_rpc->xen_arg->cmd = OPTEE_RPC_CMD_SHM_FREE; + shm_rpc->xen_arg->num_params = 1; + shm_rpc->xen_arg->params[0].attr = OPTEE_MSG_ATTR_TYPE_VALUE_INPUT; + shm_rpc->xen_arg->params[0].u.value.a = call->rpc_buffer_type; + shm_rpc->xen_arg->params[0].u.value.b = cookie; + + if ( access_guest_memory_by_ipa(current->domain, + gfn_to_gaddr(shm_rpc->gfn), + shm_rpc->xen_arg, + OPTEE_MSG_GET_ARG_SIZE(1), + true) ) + { + /* + * Well, this is quite bad. We have error in the error + * path. This can happen only if guest behaves badly, so all + * we can do is to return error to OP-TEE and leave guest's + * memory leaked. We already have freed all resources + * allocated for this buffer, but guest will never receive + * OPTEE_RPC_CMD_SHM_FREE request, so it will not know that it + * can release allocated buffer. + */ + shm_rpc->xen_arg->ret = TEEC_ERROR_GENERIC; + shm_rpc->xen_arg->num_params = 0; + + return false; + } + + uint64_to_regpair(&r1, &r2, shm_rpc->cookie); + + call->state = OPTEE_CALL_XEN_RPC; + call->rpc_op = OPTEE_SMC_RPC_FUNC_CMD; + call->rpc_params[0] = r1; + call->rpc_params[1] = r2; + call->optee_thread_id = get_user_reg(regs, 3); + + set_user_reg(regs, 0, OPTEE_SMC_RETURN_RPC_CMD); + set_user_reg(regs, 1, r1); + set_user_reg(regs, 2, r2); + + return true; +} + +/* Handles return from Xen-issued RPC */ +static void handle_xen_rpc_return(struct optee_domain *ctx, + struct cpu_user_regs *regs, + struct optee_std_call *call, + struct shm_rpc *shm_rpc) +{ + call->state = OPTEE_CALL_NORMAL; + + /* + * Right now we have only one reason to be there - we asked guest + * to free shared buffer and it did it. Now we can tell OP-TEE + * that buffer allocation failed. We are not storing exact command + * type, only type of RPC return. So, this is the only check we + * can perform there. + */ + ASSERT(call->rpc_op == OPTEE_SMC_RPC_FUNC_CMD); + + /* + * We are not checking return value from a guest because we assume + * that OPTEE_RPC_CMD_SHM_FREE never fails. + */ + shm_rpc->xen_arg->ret = TEEC_ERROR_GENERIC; + shm_rpc->xen_arg->num_params = 0; +} + /* * This function is called when guest is finished processing RPC * request from OP-TEE and wished to resume the interrupted standard * call. + * + * Return values: + * false - there was an error, do not call OP-TEE + * true - success, proceed as normal */ -static void handle_rpc_cmd_alloc(struct optee_domain *ctx, +static bool handle_rpc_cmd_alloc(struct optee_domain *ctx, struct cpu_user_regs *regs, struct optee_std_call *call, struct shm_rpc *shm_rpc) { if ( shm_rpc->xen_arg->ret || shm_rpc->xen_arg->num_params != 1 ) - return; + return true; if ( shm_rpc->xen_arg->params[0].attr != (OPTEE_MSG_ATTR_TYPE_TMEM_OUTPUT | OPTEE_MSG_ATTR_NONCONTIG) ) @@ -1269,7 +1371,7 @@ static void handle_rpc_cmd_alloc(struct optee_domain *ctx, gdprintk(XENLOG_WARNING, "Invalid attrs for shared mem buffer: %"PRIx64"\n", shm_rpc->xen_arg->params[0].attr); - return; + return true; } /* Free pg list for buffer */ @@ -1285,21 +1387,14 @@ static void handle_rpc_cmd_alloc(struct optee_domain *ctx, { call->rpc_data_cookie = 0; /* - * Okay, so there was problem with guest's buffer and we need - * to tell about this to OP-TEE. - */ - shm_rpc->xen_arg->ret = TEEC_ERROR_GENERIC; - shm_rpc->xen_arg->num_params = 0; - /* - * TODO: With current implementation, OP-TEE will not issue - * RPC to free this buffer. Guest and OP-TEE will be out of - * sync: guest believes that it provided buffer to OP-TEE, - * while OP-TEE thinks of opposite. Ideally, we need to - * emulate RPC with OPTEE_MSG_RPC_CMD_SHM_FREE command. + * We are unable to translate guest's buffer, so we need tell guest + * to free it, before reporting an error to OP-TEE. */ - gprintk(XENLOG_WARNING, - "translate_noncontig() failed, OP-TEE/guest state is out of sync.\n"); + return !issue_rpc_cmd_free(ctx, regs, call, shm_rpc, + shm_rpc->xen_arg->params[0].u.tmem.shm_ref); } + + return true; } static void handle_rpc_cmd(struct optee_domain *ctx, struct cpu_user_regs *regs, @@ -1349,22 +1444,37 @@ static void handle_rpc_cmd(struct optee_domain *ctx, struct cpu_user_regs *regs, goto out; } - switch (shm_rpc->xen_arg->cmd) + if ( call->state == OPTEE_CALL_NORMAL ) { - case OPTEE_RPC_CMD_GET_TIME: - case OPTEE_RPC_CMD_WAIT_QUEUE: - case OPTEE_RPC_CMD_SUSPEND: - break; - case OPTEE_RPC_CMD_SHM_ALLOC: - handle_rpc_cmd_alloc(ctx, regs, call, shm_rpc); - break; - case OPTEE_RPC_CMD_SHM_FREE: - free_optee_shm_buf(ctx, shm_rpc->xen_arg->params[0].u.value.b); - if ( call->rpc_data_cookie == shm_rpc->xen_arg->params[0].u.value.b ) - call->rpc_data_cookie = 0; - break; - default: - break; + switch (shm_rpc->xen_arg->cmd) + { + case OPTEE_RPC_CMD_GET_TIME: + case OPTEE_RPC_CMD_WAIT_QUEUE: + case OPTEE_RPC_CMD_SUSPEND: + break; + case OPTEE_RPC_CMD_SHM_ALLOC: + if ( !handle_rpc_cmd_alloc(ctx, regs, call, shm_rpc) ) + { + /* We failed to translate buffer, report back to guest */ + unmap_domain_page(shm_rpc->xen_arg); + put_std_call(ctx, call); + + return; + } + break; + case OPTEE_RPC_CMD_SHM_FREE: + free_optee_shm_buf(ctx, shm_rpc->xen_arg->params[0].u.value.b); + if ( call->rpc_data_cookie == + shm_rpc->xen_arg->params[0].u.value.b ) + call->rpc_data_cookie = 0; + break; + default: + break; + } + } + else + { + handle_xen_rpc_return(ctx, regs, call, shm_rpc); } out: From patchwork Wed Sep 18 18:51:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 11151157 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E4C1D112B for ; Wed, 18 Sep 2019 18:52:59 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 BC77C21D6C for ; Wed, 18 Sep 2019 18:52:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=epam.com header.i=@epam.com header.b="JgtcfhS8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC77C21D6C Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=epam.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAf2s-0006LT-55; Wed, 18 Sep 2019 18:51:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAf2q-0006Kf-B7 for xen-devel@lists.xenproject.org; Wed, 18 Sep 2019 18:51:16 +0000 X-Inumbo-ID: 44f995da-da45-11e9-a337-bc764e2007e4 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (unknown [40.107.8.43]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 44f995da-da45-11e9-a337-bc764e2007e4; Wed, 18 Sep 2019 18:51:05 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AjO/oaWLiqnM9g5n03u/3T8FGlaKQM98vl60M6a2Qp2mQIKnmKH3zC+Yr2jsnowK+l/ZFK5xvfu9Rsqmkv5DF0CiyHXrur/zNTjauzfFh6O6mpiKO6+xGcQkQk567qSNdl0KswezaGXjPr4wg6ME2GEPxzoDMCMQjwwhyU38Qc+T26kkWt7qnzWKXger20oQO2J4MMmtTZABBL0qas8ZcpXSLOEhc/7TB5n+rxIAas50i5JHzhqLbzTXrKy6l2EmXx0gwebKxATZq8CAachLGFmZdlAcWSeo3ob3hwba/4nKrA9qvFIxEJ9Ssc68V5Fx1kOJj2DaxGpKTPQqsPy9SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UeWvlhtWuBD4ntb7QEGBTsN2iWtPfNci12MkBpwkoxg=; b=jB3qpBVgqdDFSWXhTOsTwLkbSdnAD5qjAyh4r2Zut3Kd5AcnAHfjkWpYr7kQba6pfT9m8tqD7Z8gmwxo+S/nXFWhNpZlpKelu9VH7phHze3NwG0JqvwNE5bFsqY9IKEXBw0rraSa06340Xd6H5G1BDBkcpWv4agB6sk+AApLVA2MJdue8XYsy4x3lzGMWQ/4ZcWHICa2qE2kzp40/S2uzdXIzq3QGRBnvHIuJh40J0cBGvdF4fbRypcmA/wNpgDgbVyrn+IXGHqvk8PPlsHriD2UdQTk/1pefZSK9k1c31dqgpQpKxo3N744MH+sbBO65L89ekK9z9URWQUDmW5VkQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UeWvlhtWuBD4ntb7QEGBTsN2iWtPfNci12MkBpwkoxg=; b=JgtcfhS8AJWA3T7B4744/TKCGE+xo1UsgluM5/NdTxQxmlQ+SqaPk3dlP4YJk82kiMMP7R2iajNJlQaVDQTj8C5JP6xbPcOUKyvX+CgyAnvXze/fnP65Zn6EtOefekBJTFFDLQdsft+qusXhANJuR5LBjV/LwQ2xm8/z2r08Ka4= Received: from AM0PR03MB4148.eurprd03.prod.outlook.com (20.177.40.10) by AM0PR03MB5761.eurprd03.prod.outlook.com (20.179.252.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.15; Wed, 18 Sep 2019 18:51:05 +0000 Received: from AM0PR03MB4148.eurprd03.prod.outlook.com ([fe80::71e3:834d:5708:5a0a]) by AM0PR03MB4148.eurprd03.prod.outlook.com ([fe80::71e3:834d:5708:5a0a%5]) with mapi id 15.20.2199.015; Wed, 18 Sep 2019 18:51:05 +0000 From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH v2 5/6] SUPPORT.md: Describe OP-TEE mediator Thread-Index: AQHVblIGqnn1V5za7UCJVAcfeG8CpQ== Date: Wed, 18 Sep 2019 18:51:04 +0000 Message-ID: <20190918185041.22738-6-volodymyr_babchuk@epam.com> References: <20190918185041.22738-1-volodymyr_babchuk@epam.com> In-Reply-To: <20190918185041.22738-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Volodymyr_Babchuk@epam.com; x-originating-ip: [85.223.209.22] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ab811c8e-ca41-457e-b2ca-08d73c6928e1 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:AM0PR03MB5761; x-ms-traffictypediagnostic: AM0PR03MB5761:|AM0PR03MB5761: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(376002)(39860400002)(346002)(396003)(189003)(199004)(66476007)(6116002)(478600001)(14454004)(66446008)(80792005)(2616005)(55236004)(8936002)(66066001)(5660300002)(2501003)(81156014)(305945005)(7736002)(81166006)(66556008)(8676002)(256004)(71200400001)(71190400001)(99286004)(54906003)(1076003)(86362001)(26005)(11346002)(6512007)(5640700003)(2906002)(186003)(102836004)(3846002)(64756008)(4744005)(76116006)(2351001)(91956017)(6506007)(25786009)(486006)(7416002)(66946007)(36756003)(476003)(446003)(4326008)(316002)(6436002)(76176011)(6486002)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR03MB5761; H:AM0PR03MB4148.eurprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: epam.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Jh3OiARshy6W5f8qV49KN1usX4g8v8WcGyLDzMy82SRWtDiNiIvtH88ugrwkEdgLm3/Xlh/iIvuWpK199t1GP18F3ihAegOnQOS3pXP5j56cZdB+Nt5GmEhxWCXNTNv547edeC2ZcsNG+tgjucS1KePgOjHs9DPByAf4GApSUkUFEU3CLSiDW4aCsnAH7ND03Vmvekm08I7mx6Tj/x8tqBiup08W30/27bloRheTu65f5pg92br+re0A4RIBXjAR9u9nBOsQ58PcrwoEkoEmu27+eda5oCUMvuF7NPx9mESasBNX65ytzWnKufuZoaQCb+0e5cNgUNfFLtmeIYBommwQG+LNID2ZsAIIEamZesMurh25XWoHEwKOSxxob+l9fFSizkrILMu3OlhhkbDuf1HgiiWEhneRLuLtzqz9VJo= MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab811c8e-ca41-457e-b2ca-08d73c6928e1 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 18:51:05.0047 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: rUAl3bW1nPmK0XZ1R670Xai476J+Y3E0N4Tgokt7Zol9t4XQK4J5la9F/stn/emndythkUKi/J4kXMJ1zswySrnlOhEg9lUgQzg9Ad4EIwg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR03MB5761 Subject: [Xen-devel] [PATCH v2 5/6] SUPPORT.md: Describe OP-TEE mediator X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , "tee-dev@lists.linaro.org" , Julien Grall , Jan Beulich , Volodymyr Babchuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" With the latest patches to the mediator, it can be considered as Technological Preview feature. Signed-off-by: Volodymyr Babchuk Acked-by: Julien Grall --- Note for commiter: Obviously this patch should be merged after all other patches in this series. --- SUPPORT.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SUPPORT.md b/SUPPORT.md index 375473a456..8d50a72dcb 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -660,6 +660,10 @@ No support for QEMU backends in a 16K or 64K domain. Status: Supported +### ARM: OP-TEE Mediator + + Status: Tech Preview + ## Virtual Hardware, QEMU This section describes supported devices available in HVM mode using a From patchwork Wed Sep 18 18:51:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 11151151 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 10B1D112B for ; Wed, 18 Sep 2019 18:52:33 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 DEE3021928 for ; Wed, 18 Sep 2019 18:52:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=epam.com header.i=@epam.com header.b="GMo9Sc3H" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DEE3021928 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=epam.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAf2w-0006O8-HE; Wed, 18 Sep 2019 18:51:22 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAf2v-0006NS-AD for xen-devel@lists.xenproject.org; Wed, 18 Sep 2019 18:51:21 +0000 X-Inumbo-ID: 46790abc-da45-11e9-978d-bc764e2007e4 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (unknown [40.107.8.42]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 46790abc-da45-11e9-978d-bc764e2007e4; Wed, 18 Sep 2019 18:51:08 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h55enY2AF+bLBBSdmrlZlUV27GcQ0kW5AsX6FjNcUHEVhR6Lq6Ebl+ycjwbsSgR1bxsKrZ/mIrnbZZxGlsu48+aPgxQK2vUV/FyqXlDDhQ4CYCqL/K8ha17CeWZFpuGWRU0QBx3Wb0XNaCEh3XaFg/RONiJ/3RAhVEqJ/wQPgPvMPlV6ptwCv4MEoMl4VPaq3ZMb0XhQUpllqItu7heK2mQhq0N4/hSOavjP3pyJwCd6W5LAIdMComfRJWgTIQQmgLK6GY3A33HNhq+G1JKmaRWmXTMdjve2UKBh1+JovPbMkLFJKcxRDhIh9H3G6ZT4bN2tIWYGOW9tpW6y3iCYJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YCVoa2GAD67/GurLR3WHoCdGmxTn0Rmps4y56oV/E2s=; b=ZRSSp8KaPECAjQ26rrM1TkzC9fcabIOqHgBO71YY4TPsgq7IlB0K0TCOZ4f+5oMTkos3hp1bNPuajUiguJPKBE9WrC1J1tlODutsk9r9mqiDB3N6EH0GPu/aWyQt1DgZ6JSmn04TDVURFplfyqNy3kinUKsDM/TtHJf6wmGiJ9/W80CXAX0Gi1qJIwae6GzvpnmByNfDE3VgmtuLSme9I0GaBSIP6wNvqwQvqSsU2Pz9Z5oF6gwm8rxi30A+1p9CMe8bcNGkkWiraAFiy1YOvIzovxeULU/KTRsSLjpVYcKRj1w9F7kM8P2KBvNFj4k3UjMiJrxGzDufSFOJw+wu7w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YCVoa2GAD67/GurLR3WHoCdGmxTn0Rmps4y56oV/E2s=; b=GMo9Sc3HKaBNHBd3DcduRenCpubMXS8NgeUIdxPQkmFMearchJ7rPTaU+qt0J1GXg/r6U6+KLRVMLXL+YvdA7N1rPVmAd6LC6tOIkMZ4kJgPq5rT9OVy+fePgnl+OAWIwK1eXD/8sQBTiQZBfCYC9Jd9ZvdcmFyfTkU3j7XQheA= Received: from AM0PR03MB4148.eurprd03.prod.outlook.com (20.177.40.10) by AM0PR03MB5761.eurprd03.prod.outlook.com (20.179.252.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.15; Wed, 18 Sep 2019 18:51:07 +0000 Received: from AM0PR03MB4148.eurprd03.prod.outlook.com ([fe80::71e3:834d:5708:5a0a]) by AM0PR03MB4148.eurprd03.prod.outlook.com ([fe80::71e3:834d:5708:5a0a%5]) with mapi id 15.20.2199.015; Wed, 18 Sep 2019 18:51:07 +0000 From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH v2 6/6] xen/arm: optee: update description in Kconfig Thread-Index: AQHVblIHV7dQjvLf+kWDWtyVMQZofA== Date: Wed, 18 Sep 2019 18:51:07 +0000 Message-ID: <20190918185041.22738-7-volodymyr_babchuk@epam.com> References: <20190918185041.22738-1-volodymyr_babchuk@epam.com> In-Reply-To: <20190918185041.22738-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Volodymyr_Babchuk@epam.com; x-originating-ip: [85.223.209.22] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 812e6c6d-b940-4145-0b8e-08d73c692a3a x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:AM0PR03MB5761; x-ms-traffictypediagnostic: AM0PR03MB5761:|AM0PR03MB5761: x-ms-exchange-transport-forked: True x-ms-exchange-purlcount: 1 x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 01644DCF4A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(376002)(39860400002)(346002)(396003)(189003)(199004)(66476007)(6116002)(478600001)(14454004)(66446008)(80792005)(2616005)(55236004)(8936002)(966005)(6306002)(66066001)(5660300002)(2501003)(81156014)(305945005)(7736002)(81166006)(66556008)(8676002)(256004)(71200400001)(14444005)(15650500001)(71190400001)(99286004)(54906003)(1076003)(86362001)(26005)(11346002)(6512007)(5640700003)(2906002)(186003)(102836004)(3846002)(64756008)(76116006)(2351001)(91956017)(6506007)(25786009)(486006)(66946007)(36756003)(476003)(446003)(4326008)(316002)(6436002)(76176011)(6486002)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR03MB5761; H:AM0PR03MB4148.eurprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: epam.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 1yg2kTi++b3M62QcKj4rdGH1BBaM7CB/xhSHYcpXOuB+OZfoBE4MZVjRMFwOLMrZCWHHzC47Pl1+mI8/aO6eJD2v1+vRbI0G8FJh6zhy1zw7JVmHmTiuueaoqSqPOyofttNBFFSFY9hc+7G6FTkvvM4b9IWQF3pOoqm8YTYV3L3N8J099tjoUhC13943agUqI89XNolyMBfSnYZdahEl46agtbG8ueFs6RXuKKe/NB/wZBbfoU7PsMtAYVx6f5AZs0rT6m+MZCv3HlBwIgOVnVngdvpZVEtUaJ4bsbW6drXIqVJQdSS14ZFfdt+kuBwEawRvI/f//H6XKJSDovVjrmyBezwiqitsPksOGby2ZydnULiNQP6zsD5Rq8b8bkIvdYybg8jM8TTk2GlcZJYZE55JDyUJ2fKDmlMGWDdOF+8= MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-Network-Message-Id: 812e6c6d-b940-4145-0b8e-08d73c692a3a X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2019 18:51:07.3044 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Q4aCS8McfLmrH5SfCTCrQllp0YTkZI4DKfbQSmUBmiaJKwQg/g+RlU7OAmXYgZjKVBmkJzTBOLNUaJuwtbTj7YO52Ad7GtgAtnmRCD7jokE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR03MB5761 Subject: [Xen-devel] [PATCH v2 6/6] xen/arm: optee: update description in Kconfig X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: "tee-dev@lists.linaro.org" , Julien Grall , Stefano Stabellini , Volodymyr Babchuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" OP-TEE mediator now is "Tech Preview" state, and we want to update it's description in Kconfig accordingly. Signed-off-by: Volodymyr Babchuk --- Note to commiter: this patch depends on first 4 patches in the series. --- xen/arch/arm/tee/Kconfig | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/tee/Kconfig b/xen/arch/arm/tee/Kconfig index b4b6aa2610..a4a598191e 100644 --- a/xen/arch/arm/tee/Kconfig +++ b/xen/arch/arm/tee/Kconfig @@ -3,7 +3,11 @@ config OPTEE default n depends on TEE help - Enable experimental OP-TEE mediator. It allows guests to access - OP-TEE running on your platform. This requires virtualization-enabled - OP-TEE present. You can learn more about virtualization for OP-TEE - at https://optee.readthedocs.io/architecture/virtualization.html + Enable the OP-TEE mediator. It allows guests to access + OP-TEE running on your platform. This requires + virtualization-enabled OP-TEE present. You can learn more + about virtualization for OP-TEE at + https://optee.readthedocs.io/architecture/virtualization.html + + Right now OP-TEE mediator is "Tech Preview" state, so it is + not good idea to use it in production.