[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 2/5] xen/arm: optee: check for preemption while freeing shared buffers


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Fri, 23 Aug 2019 18:48:47 +0000
  • Accept-language: en-US
  • 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
  • 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-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jiISmk9ckQpR6GwDgxIl1J8k3RIBES/lZ8rGQqpDT936QMHcwnMN0yTrPyHyZnA7kSXIWTfeJD+CmLbdQOT/r2ebbpLmRzIbUaSpm+Zuybhir2oUPnhkCvN/ANOiKHQWPvvX1LAOc2Qaw83JWSy3gOXx6HlPmv28fuTHb5VpAo+4noCOFmLS5nHF7O56BITdeCRUc299Yu+wIAr5IL4E7Y9U7QcmvRjXilNmePrV48pnCPTnZdCN/d4VVuRclBStCyLeeEmtRLTiy4LHPANb7vJqVx5bOkmys8RBiRnsIqDvq8Wit1wKLTMJJAgMSggd+OJTk6s39iOR2HPPBJpNWQ==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Volodymyr_Babchuk@xxxxxxxx;
  • Cc: "tee-dev@xxxxxxxxxxxxxxxx" <tee-dev@xxxxxxxxxxxxxxxx>, Julien Grall <julien.grall@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 23 Aug 2019 18:49:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHVWeNlIytwW28PUEKII1lAK5bjtQ==
  • Thread-topic: [PATCH 2/5] xen/arm: optee: check for preemption while freeing shared buffers

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 <volodymyr_babchuk@xxxxxxxx>
---
 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;
-- 
2.22.0

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.