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

[PATCH v1 10/13] xen/arm: allocate static shared memory to a specific owner domain


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Fri, 11 Mar 2022 14:11:20 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QR0uJjdb78Gry1GYCYAG5IJdQ9AYTo5LJTpZNi0Eqhs=; b=XraXeDJXZ/zfLgwdOHGgrydQjBK7N2CXPqdy5XwAGnccLRNcaOWO/EkRSRzZM1VnB0E5Ui/1IZ8T+GrHkPi2zkXnybtw2wN1231xEgmYrfkv7zWgXoLAmJQyZKimMDtDYSidvK07DZvM1pXlNWrTpd6ro9GDh6ACtFVf/0HGv8lUPvb8ATguRaih7o0uqZIQvRlkBIDtDoEerL7TthysMqXXgLWXuRBOSBX6FFf4L9dslSAcYSM0w7Uu+AvQSVYmylXsuaNRh8XdCtiW8q1uPkGN/3PNHOFIF9I2Y6fP1q705quWnHNUeEwcoU/ErWKnZN8A2EdAbAaZRSYpO5gA3g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oHu5dKgOJ+pgs8bNfw/cSrIDupk6kfjdTGZDEyT/Wl9H7QUCSOZvzEPvy4KZ6djM90bskw67q3fuNIm/g2Q3Yi9zteaWZR2M02ryl8utJR40ooJoWoEW5wbnOFaC4F2XYQSh/ytqM1agPb1QSiZWPlU1QALOjkqMmeg9wLcwRvh18ajfs40ifSL8kXWWMkDgT4ZvcCFwDVZyKsHMqA4U1yOfGlPDzJRXiW4Q4tqFg4t9E74vK/GnFoX+0x+xn5m2yY0Ozooh0qo11GUAOKcL3nZQpQx9DAz1Ck+1FEuF45AnntY8xOx4z62IG8nAglLDVQXWwBMly2VBcyQdKc5ZCw==
  • Cc: <nd@xxxxxxx>, Penny Zheng <penny.zheng@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 11 Mar 2022 06:13:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true

From: Penny Zheng <penny.zheng@xxxxxxx>

If owner property is defined, then owner domain of a static shared memory
region is not the default dom_shared anymore, but a specific domain.

This commit implements allocating static shared memory to a specific domain
when owner property is defined.

Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
---
 xen/arch/arm/domain_build.c | 63 ++++++++++++++++++++++++++++---------
 1 file changed, 48 insertions(+), 15 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index d35f98ff9c..7ee4d33e0b 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -872,6 +872,8 @@ static int __init process_shm(struct domain *d,
     u32 shm_id;
     u32 addr_cells, size_cells;
     paddr_t gbase, pbase, psize;
+    const char *role_str;
+    bool owner_dom_shared = true;
 
     dt_for_each_child_node(node, shm_node)
     {
@@ -899,6 +901,13 @@ static int __init process_shm(struct domain *d,
         gbase = dt_read_number(cells, addr_cells);
 
         /* TODO: Consider owner domain is not the default dom_shared. */
+        /*
+         * "role" property is optional and if it is defined explicitly,
+         * so the owner domain is not the default "dom_shared" domain.
+         */
+        if ( dt_property_read_string(shm_node, "role", &role_str) == 0 )
+            owner_dom_shared = false;
+
         /*
          * Per shared memory region could be shared between multiple domains.
          * In case re-allocating the same shared memory region, we use bitmask
@@ -907,17 +916,38 @@ static int __init process_shm(struct domain *d,
          */
         if ( !test_bit(shm_id, shm_mask) )
         {
-            /*
-             * Allocate statically shared pages to the default dom_shared.
-             * Set up P2M, and dom_shared is a direct-map domain,
-             * so GFN == PFN.
-             */
-            ret = allocate_shared_memory(dom_shared, addr_cells, size_cells,
-                                         pbase, psize, pbase);
-            if ( ret )
-                return ret;
-
-            set_bit(shm_id, shm_mask);
+            if ( !owner_dom_shared )
+            {
+                if ( strcmp(role_str, "owner") == 0 )
+                {
+                    /*
+                     * Allocate statically shared pages to a specific owner
+                     * domain.
+                     */
+                    ret = allocate_shared_memory(d, shm_id, addr_cells,
+                                                 size_cells, pbase, psize,
+                                                 gbase);
+                    if ( ret )
+                        return ret;
+
+                    set_bit(shm_id, shm_mask);
+                }
+            }
+            else
+            {
+                /*
+                 * Allocate statically shared pages to the default dom_shared.
+                 * Set up P2M, and dom_shared is a direct-map domain,
+                 * so GFN == PFN.
+                 */
+                ret = allocate_shared_memory(dom_shared, shm_id,
+                                             addr_cells, size_cells, pbase,
+                                             psize, pbase);
+                if ( ret )
+                    return ret;
+
+                set_bit(shm_id, shm_mask);
+            }
         }
 
         /*
@@ -925,10 +955,13 @@ static int __init process_shm(struct domain *d,
          * default dom_shared, so here we could just set up P2M foreign
          * mapping for borrower domain immediately.
          */
-        ret = guest_physmap_add_shm(dom_shared, d, PFN_DOWN(pbase),
-                                    PFN_DOWN(gbase), PFN_DOWN(psize));
-        if ( ret )
-            return ret;
+        if ( owner_dom_shared )
+        {
+            ret = guest_physmap_add_shm(dom_shared, d, PFN_DOWN(pbase),
+                                        PFN_DOWN(gbase), PFN_DOWN(psize));
+            if ( ret )
+                return ret;
+        }
 
         /*
          * Record static shared memory region info for later setting
-- 
2.25.1




 


Rackspace

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