All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Fancellu <luca.fancellu@arm.com>
To: xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Michal Orzel <michal.orzel@amd.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: [PATCH 11/11] xen/arm: List static shared memory regions as /memory nodes
Date: Tue, 12 Mar 2024 13:03:31 +0000	[thread overview]
Message-ID: <20240312130331.78418-12-luca.fancellu@arm.com> (raw)
In-Reply-To: <20240312130331.78418-1-luca.fancellu@arm.com>

Currently Xen is not exporting the static shared memory regions
to the device tree as /memory node, this commit is fixing this
issue.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
---
 xen/arch/arm/dom0less-build.c           |  5 +++
 xen/arch/arm/domain_build.c             |  7 +++-
 xen/arch/arm/include/asm/static-shmem.h |  5 ++-
 xen/arch/arm/static-shmem.c             | 54 +++++++++++++++----------
 4 files changed, 47 insertions(+), 24 deletions(-)

diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c
index fe2a771d4984..0892020f21a0 100644
--- a/xen/arch/arm/dom0less-build.c
+++ b/xen/arch/arm/dom0less-build.c
@@ -647,6 +647,11 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo)
     if ( ret )
         goto err;
 
+    /* List static shared memory regions as /memory@<address> nodes */
+    ret = make_shm_memory_node(d, kinfo, addrcells, sizecells, false);
+    if ( ret )
+        return ret;
+
     ret = make_resv_memory_node(d, kinfo, addrcells, sizecells);
     if ( ret )
         goto err;
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 575e906d81a6..bd7716cd5829 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1723,7 +1723,7 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo,
          * static shared memory nodes there.
          */
         res = make_shm_memory_node(d, kinfo, dt_n_addr_cells(node),
-                                   dt_n_size_cells(node));
+                                   dt_n_size_cells(node), true);
         if ( res )
             return res;
     }
@@ -1780,6 +1780,11 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo,
                 return res;
         }
 
+        /* List static shared memory regions as /memory@<address> nodes */
+        res = make_shm_memory_node(d, kinfo, addrcells, sizecells, false);
+        if ( res )
+            return res;
+
         if ( !res_mem_node_found )
         {
             res = make_resv_memory_node(d, kinfo, addrcells, sizecells);
diff --git a/xen/arch/arm/include/asm/static-shmem.h b/xen/arch/arm/include/asm/static-shmem.h
index d28b9540d49b..c118bbb1c43b 100644
--- a/xen/arch/arm/include/asm/static-shmem.h
+++ b/xen/arch/arm/include/asm/static-shmem.h
@@ -37,7 +37,7 @@ int remove_shm_holes_for_domU(const struct kernel_info *kinfo,
 
 int make_shm_memory_node(const struct domain *d,
                          const struct kernel_info *kinfo, int addrcells,
-                         int sizecells);
+                         int sizecells, bool is_resv_mem_node);
 
 #else /* !CONFIG_STATIC_SHM */
 
@@ -85,7 +85,8 @@ static inline int remove_shm_holes_for_domU(const struct kernel_info *kinfo,
 
 static inline int make_shm_memory_node(const struct domain *d,
                                        const struct kernel_info *kinfo,
-                                       int addrcells, int sizecells)
+                                       int addrcells, int sizecells,
+                                       bool is_resv_mem_node)
 {
     return 0;
 }
diff --git a/xen/arch/arm/static-shmem.c b/xen/arch/arm/static-shmem.c
index 67d5fa3b5d25..cdaf4485c934 100644
--- a/xen/arch/arm/static-shmem.c
+++ b/xen/arch/arm/static-shmem.c
@@ -289,7 +289,7 @@ int __init process_shm(struct domain *d, struct kernel_info *kinfo,
 
 int __init make_shm_memory_node(const struct domain *d,
                                 const struct kernel_info *kinfo, int addrcells,
-                                int sizecells)
+                                int sizecells, bool is_resv_mem_node)
 {
     const struct membanks *mem = &kinfo->shm_mem.common;
     void *fdt = kinfo->fdt;
@@ -300,11 +300,15 @@ int __init make_shm_memory_node(const struct domain *d,
         return 0;
 
     /*
-     * For each shared memory region, a range is exposed under
-     * the /reserved-memory node as a child node. Each range sub-node is
-     * named xen-shmem@<address>.
+     * When is_resv_mem_node is true, it means this function is called to
+     * create nodes under /reserved-memory, so for each shared memory region, a
+     * range is exposed under the /reserved-memory node as a child node. Each
+     * range sub-node is named xen-shmem@<address>.
+     * Otherwise the function is called under / and will create
+     * /memory@<address> nodes for each static shared memory region.
      */
-    dt_dprintk("Create xen-shmem node\n");
+    dt_dprintk("Create static shared memory %s nodes\n",
+               is_resv_mem_node ? "/reserved-memory/xen-shmem" : "/memory");
 
     for ( ; i < mem->nr_banks; i++ )
     {
@@ -316,11 +320,16 @@ int __init make_shm_memory_node(const struct domain *d,
         __be32 *cells;
         unsigned int len = (addrcells + sizecells) * sizeof(__be32);
 
-        res = domain_fdt_begin_node(fdt, "xen-shmem", mem->bank[i].start);
+        res = domain_fdt_begin_node(fdt,
+                                    is_resv_mem_node ? "xen-shmem" : "memory",
+                                    mem->bank[i].start);
         if ( res )
             return res;
 
-        res = fdt_property(fdt, "compatible", compat, sizeof(compat));
+        if ( is_resv_mem_node )
+            res = fdt_property(fdt, "compatible", compat, sizeof(compat));
+        else
+            res = fdt_property_string(fdt, "device_type", "memory");
         if ( res )
             return res;
 
@@ -334,20 +343,23 @@ int __init make_shm_memory_node(const struct domain *d,
         dt_dprintk("Shared memory bank %u: %#"PRIx64"->%#"PRIx64"\n",
                    i, start, start + size);
 
-        res = fdt_property_string(fdt, "xen,id",
-                                  mem->bank[i].shmem_extra->shm_id);
-        if ( res )
-            return res;
+        if ( is_resv_mem_node )
+        {
+            res = fdt_property_string(fdt, "xen,id",
+                                      mem->bank[i].shmem_extra->shm_id);
+            if ( res )
+                return res;
 
-        /*
-         * TODO:
-         * - xen,offset: (borrower VMs only)
-         *   64 bit integer offset within the owner virtual machine's shared
-         *   memory region used for the mapping in the borrower VM
-         */
-        res = fdt_property_u64(fdt, "xen,offset", 0);
-        if ( res )
-            return res;
+            /*
+            * TODO:
+            * - xen,offset: (borrower VMs only)
+            *   64 bit integer offset within the owner virtual machine's shared
+            *   memory region used for the mapping in the borrower VM
+            */
+            res = fdt_property_u64(fdt, "xen,offset", 0);
+            if ( res )
+                return res;
+        }
 
         res = fdt_end_node(fdt);
         if ( res )
@@ -536,7 +548,7 @@ int __init make_resv_memory_node(const struct domain *d,
     if ( res )
         return res;
 
-    res = make_shm_memory_node(d, kinfo, addrcells, sizecells);
+    res = make_shm_memory_node(d, kinfo, addrcells, sizecells, true);
     if ( res )
         return res;
 
-- 
2.34.1



  parent reply	other threads:[~2024-03-12 13:04 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12 13:03 [PATCH 00/11] Static shared memory followup v2 - pt1 Luca Fancellu
2024-03-12 13:03 ` [PATCH 01/11] xen/arm: remove stale addr_cells/size_cells in assign_shared_memory Luca Fancellu
2024-03-12 13:03 ` [PATCH 02/11] xen/arm: avoid repetitive checking in process_shm_node Luca Fancellu
2024-03-19 10:57   ` Michal Orzel
2024-03-12 13:03 ` [PATCH 03/11] xen/arm: Introduce a generic way to access memory bank structures Luca Fancellu
2024-03-19 13:10   ` Michal Orzel
2024-03-19 13:30     ` Luca Fancellu
2024-03-20  9:30     ` Julien Grall
2024-03-12 13:03 ` [PATCH 04/11] xen/arm: Conditional compilation of kernel_info.shm_mem member Luca Fancellu
2024-03-19 14:58   ` Michal Orzel
2024-04-04  9:27     ` Luca Fancellu
2024-04-04  9:33       ` Michal Orzel
2024-03-12 13:03 ` [PATCH 05/11] xen/arm: Introduce helper for static memory pages Luca Fancellu
2024-03-20 10:41   ` Michal Orzel
2024-03-12 13:03 ` [PATCH 06/11] xen/arm: Avoid code duplication in find_unallocated_memory Luca Fancellu
2024-03-20 10:57   ` Michal Orzel
2024-03-20 14:53     ` Luca Fancellu
2024-03-21  9:02       ` Michal Orzel
2024-03-12 13:03 ` [PATCH 07/11] xen/arm: Avoid code duplication in check_reserved_regions_overlap Luca Fancellu
2024-03-12 13:03 ` [PATCH 08/11] xen/arm: Reduce struct membank size on static shared memory Luca Fancellu
2024-03-22 10:30   ` Michal Orzel
2024-04-04  9:33     ` Luca Fancellu
2024-04-04 11:19       ` Michal Orzel
2024-03-12 13:03 ` [PATCH 09/11] xen/arm: remove shm holes for extended regions Luca Fancellu
2024-03-22 15:09   ` Michal Orzel
2024-03-22 20:11     ` Luca Fancellu
2024-03-12 13:03 ` [PATCH 10/11] xen/arm: fix duplicate /reserved-memory node in Dom0 Luca Fancellu
2024-03-25  8:09   ` Michal Orzel
2024-03-12 13:03 ` Luca Fancellu [this message]
2024-03-25  8:58   ` [PATCH 11/11] xen/arm: List static shared memory regions as /memory nodes Michal Orzel
2024-03-26 14:19     ` Luca Fancellu
2024-03-27  8:27       ` Michal Orzel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240312130331.78418-12-luca.fancellu@arm.com \
    --to=luca.fancellu@arm.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=bertrand.marquis@arm.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.