From patchwork Fri Aug 23 18:48:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 11112227 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 5BB1914DE for ; Fri, 23 Aug 2019 18:50:53 +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 35C1821874 for ; Fri, 23 Aug 2019 18:50:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=epam.com header.i=@epam.com header.b="PYDvDl6o" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 35C1821874 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 1i1EcG-0001iI-V4; Fri, 23 Aug 2019 18:48:52 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i1EcF-0001i3-8p for xen-devel@lists.xenproject.org; Fri, 23 Aug 2019 18:48:51 +0000 X-Inumbo-ID: a56b2060-c5d6-11e9-adef-12813bfff9fa Received: from EUR01-VE1-obe.outbound.protection.outlook.com (unknown [40.107.14.44]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a56b2060-c5d6-11e9-adef-12813bfff9fa; Fri, 23 Aug 2019 18:48:50 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jiISmk9ckQpR6GwDgxIl1J8k3RIBES/lZ8rGQqpDT936QMHcwnMN0yTrPyHyZnA7kSXIWTfeJD+CmLbdQOT/r2ebbpLmRzIbUaSpm+Zuybhir2oUPnhkCvN/ANOiKHQWPvvX1LAOc2Qaw83JWSy3gOXx6HlPmv28fuTHb5VpAo+4noCOFmLS5nHF7O56BITdeCRUc299Yu+wIAr5IL4E7Y9U7QcmvRjXilNmePrV48pnCPTnZdCN/d4VVuRclBStCyLeeEmtRLTiy4LHPANb7vJqVx5bOkmys8RBiRnsIqDvq8Wit1wKLTMJJAgMSggd+OJTk6s39iOR2HPPBJpNWQ== 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=h9slQsESnMOdoeXOxnMo+h2DWjSwXDwU5+fCRetsgFU=; b=BRWrW66MwH842tr5sIyMhDFckjrFqtz2rsGKnoHbEM+oqblTbEKDMyWYYg/NFnoiPEE5SrPGSS+RjGxylQry1Hpjbkuc+9QEvgNlen2COSrpDbemp5yNf3divs02yF8t06Ue4kpewnRWCJ6qDwsBay09eRZodwE8vA8/htmYeEfsRIISqlPUnzDW1PrGdNZahhup2Y0MhpgSZ/8cnSf2SWVPd15o7+husBsJ4kq/CDz0ExD4VVI7tjFfuFL2iDyfqwtg5Kloo4Rn/l4RFcnvCsJlJP7Grq5UiWZkGP55JynZYkQc853ZsOCdaQKc9unyw3Z6ImHGb26tCbbnMoacGw== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h9slQsESnMOdoeXOxnMo+h2DWjSwXDwU5+fCRetsgFU=; b=PYDvDl6oYhM6ewlKhCT/aZYxX5wxgG1nOOK+tfaC4RTP/6E0iTI4EZIN4SGEmh/hgewWYLWKa2sHabo3xF4ekmuEn71TZoU11X49zBvJK6h3kQu1Tlt94Ky7Pe1G0tKEZ7V16PolHXycV0kvQ/YYZWwSnoBxLdl2qqvs6MOTylRMlDRrtOe+sEJ+14ucis9X2NQxDw3SMoY2p5a5LdJVSEOMyLg1e6xiwZNc7yWDapnIbLVAdMc8IOYtNEIlin0krcf9lYKEnYnJEbWCsBZ/unK0kRdP4Ljrx4sh74nHjGL8//lcrBKyFCVSGtCiTAdkbJWc8KED0EUXNpzIsiYUkg== Received: from AM0PR03MB4148.eurprd03.prod.outlook.com (20.177.40.10) by AM0PR03MB4690.eurprd03.prod.outlook.com (20.177.41.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.18; Fri, 23 Aug 2019 18:48:48 +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; Fri, 23 Aug 2019 18:48:48 +0000 From: Volodymyr Babchuk To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH 2/5] xen/arm: optee: check for preemption while freeing shared buffers Thread-Index: AQHVWeNlIytwW28PUEKII1lAK5bjtQ== Date: Fri, 23 Aug 2019 18:48:47 +0000 Message-ID: <20190823184826.14525-3-volodymyr_babchuk@epam.com> References: <20190823184826.14525-1-volodymyr_babchuk@epam.com> In-Reply-To: <20190823184826.14525-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: 6f2ed6bf-b848-459b-4dd0-08d727fa8891 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:AM0PR03MB4690; x-ms-traffictypediagnostic: AM0PR03MB4690:|AM0PR03MB4690: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 0138CD935C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(346002)(136003)(376002)(39860400002)(366004)(396003)(189003)(199004)(6436002)(305945005)(25786009)(76176011)(81166006)(71190400001)(478600001)(7736002)(81156014)(5660300002)(8676002)(71200400001)(4326008)(186003)(6506007)(99286004)(2351001)(6486002)(1076003)(2501003)(26005)(2906002)(6916009)(66446008)(55236004)(66946007)(91956017)(14454004)(76116006)(66476007)(66556008)(36756003)(64756008)(6116002)(6512007)(446003)(11346002)(3846002)(476003)(2616005)(316002)(54906003)(86362001)(80792005)(102836004)(5640700003)(8936002)(66066001)(14444005)(486006)(256004)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR03MB4690; 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: 1bMtjGHCJ3Kmw55s8ZSqZeXbGXHZdcm2e2g/0GF92hBtF9tsRHTWsY8BeiudbSGQuKKVNyiNyGPCnjO4udvJMAWoZvqofrJz+l/74Mt7ezJBgacIQBWkL0cfv8h0vn60gHnatlDDAzmqr20q4tf2Tztd4UORu2zy3Zxq4XfywRTgXAF9T3eIEGETnksoa7DVUt9ET+5eIntcuTjQ7FvOtB5Nazv0wsgoI+pVTbgQMQGRmFI7SRXqlQH6/jO6Y1C18UkQkbL14CFkU/3bbaIkUduod07xJHzuHQqHh1cHz/QZv+7hhBoJeVbQWpeGeK9SjV0xEoTBXOEx2QiMdxkWKjTMFnFaJZqS5V+4mggz1Cg8JEU1+fGPaPbQNa7htTB/EbXrmKn2maGdIutBY6Smgn/Hh3Q5l6JImP5fsGOWKbQ= MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f2ed6bf-b848-459b-4dd0-08d727fa8891 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Aug 2019 18:48:48.0537 (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: 1bTAAWNXqfFEsIsvsJdAqZsYPlc2oVxYQnSsc8LRP9Wwl8PzGpayYRiNDaY2zPP1FJUKVhIJhB0zXDEI1LNdjnVzu3CR1mOOAgEd6gun7BA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR03MB4690 Subject: [Xen-devel] [PATCH 2/5] 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" Now we have limit for one shared buffer size, so we can be sure that one call to free_optee_shm_buf() will not free all MAX_TOTAL_SMH_BUF_PG pages at once. Thus, we now can check for hypercall_preempt_check() in the loop inside optee_relinquish_resources() and this will ensure that we are not missing preemption. Signed-off-by: Volodymyr Babchuk --- xen/arch/arm/tee/optee.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c index f4fa8a7758..a84ffa3089 100644 --- a/xen/arch/arm/tee/optee.c +++ b/xen/arch/arm/tee/optee.c @@ -634,14 +634,14 @@ static int optee_relinquish_resources(struct domain *d) 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;