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

[PATCH v5 03/24] xen/arm: move dt_find_node_by_gpath() to passthrough/device_tree.c


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Fri, 12 Dec 2025 12:01:48 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=YXAQFART80WLThJjcvr6ZzdrnhTVp/Mdx6r3fmkmkIU=; b=FlfiKf8JIV23MnTnQeJIPecEzltaOXlsBZsX4bpBSTI6ewPNDgii+SQ7/CxdHvDjtCWw6ID6b6VpGmCGl0GNxE3/bAjL1AlydDGgcrLzySdjl7NE2yS0Y9YcfVKAbN5CERpPJOuKvXhwCDfpSgttL4WfzQVmYQ1CsZIPQck1/ZmP/HVeHS7gAJHaJmKPFb6pouRxeruglqAgKNqwdcbuo/IysYZ88rsgIK/c5W19TEDBm0sk7wU2VCJAFGWGBaLUP2E8r6xFH1Q46clnu4Jl32RsPpkx1izbSWgEpsTne/v3AGUNqzmLXHoaAigvkCIDaHGmQjjshuAFxxwHVdd4/Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZaKiUXk4MzO/A9ATcrJfmwQ3GEdtj1ywfMcL6LVVRhblUcO6620R0y9c9M9O+FVNXSjzlVy6NPtCbf/0DnLFX3CScMmwXtxSZdEKWYmXPh2UJ0jZ0WoU8iI6Uhv/1NqH7/hAiHhwTDkbmT/od3Ewj0WWX/sYHa8cJJW+WAB+OY2TecutTdr+Q6SUyTbERQJIqZI0sjvuDiFqrBMgnycKheEzE5Unk7uq4h/ycMdQPg4j3X66fVc4iusOLCXR9YXbj3tpnrVbX/LnDA9trC4RKSTUt4tvQ77d7IbTzSZc/r/pQgFfQhKobifJev8VMvSUs0Gsrv77o8GKQI0fYT4/OA==
  • Cc: <ray.huang@xxxxxxx>, <grygorii_strashko@xxxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Julien Grall" <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, "Michal Orzel" <michal.orzel@xxxxxxx>, Penny Zheng <penny.zheng@xxxxxxx>
  • Delivery-date: Fri, 12 Dec 2025 04:06:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The common/device-tree/device-tree.c contains generic unflatten DT helpers API,
while dt_find_node_by_gpath() is specific for domctl (iommu) processing.
We move this function into drivers\passthrough\device_tree.c and make it
static, as it is used only there now.

Suggested-by: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
---
v4 -> v5:
- new commit
---
 xen/common/device-tree/device-tree.c  | 16 ---------------
 xen/drivers/passthrough/device_tree.c | 28 +++++++++++++++++++++++++++
 xen/include/xen/device_tree.h         | 13 -------------
 3 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/xen/common/device-tree/device-tree.c 
b/xen/common/device-tree/device-tree.c
index 0b5375f151..d6cf417e94 100644
--- a/xen/common/device-tree/device-tree.c
+++ b/xen/common/device-tree/device-tree.c
@@ -371,22 +371,6 @@ struct dt_device_node *dt_find_node_by_path_from(struct 
dt_device_node *from,
     return np;
 }
 
-int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path, uint32_t u_plen,
-                          struct dt_device_node **node)
-{
-    char *path;
-
-    path = safe_copy_string_from_guest(u_path, u_plen, PAGE_SIZE);
-    if ( IS_ERR(path) )
-        return PTR_ERR(path);
-
-    *node = dt_find_node_by_path(path);
-
-    xfree(path);
-
-    return (*node == NULL) ? -ESRCH : 0;
-}
-
 struct dt_device_node *dt_find_node_by_alias(const char *alias)
 {
     const struct dt_alias_prop *app;
diff --git a/xen/drivers/passthrough/device_tree.c 
b/xen/drivers/passthrough/device_tree.c
index f5850a2607..eb0c233977 100644
--- a/xen/drivers/passthrough/device_tree.c
+++ b/xen/drivers/passthrough/device_tree.c
@@ -16,6 +16,7 @@
  */
 
 #include <xen/device_tree.h>
+#include <xen/err.h>
 #include <xen/guest_access.h>
 #include <xen/iommu.h>
 #include <xen/lib.h>
@@ -318,6 +319,33 @@ int iommu_add_dt_device(struct dt_device_node *np)
     return rc;
 }
 
+/*
+ * dt_find_node_by_gpath - Same as dt_find_node_by_path but retrieve the
+ * path from the guest
+ *
+ * @u_path: Xen Guest handle to the buffer containing the path
+ * @u_plen: Length of the buffer
+ * @node: TODO
+ *
+ * Return 0 if succeed otherwise -errno
+ */
+static int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path,
+                                 uint32_t u_plen,
+                                 struct dt_device_node **node)
+{
+    char *path;
+
+    path = safe_copy_string_from_guest(u_path, u_plen, PAGE_SIZE);
+    if ( IS_ERR(path) )
+        return PTR_ERR(path);
+
+    *node = dt_find_node_by_path(path);
+
+    xfree(path);
+
+    return (*node == NULL) ? -ESRCH : 0;
+}
+
 int iommu_do_dt_domctl(struct xen_domctl *domctl, struct domain *d,
                        XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
 {
diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index 06d7643622..241f269b57 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -550,19 +550,6 @@ static inline struct dt_device_node 
*dt_find_node_by_path(const char *path)
     return dt_find_node_by_path_from(dt_host, path);
 }
 
-/**
- * dt_find_node_by_gpath - Same as dt_find_node_by_path but retrieve the
- * path from the guest
- *
- * @u_path: Xen Guest handle to the buffer containing the path
- * @u_plen: Length of the buffer
- * @node: TODO
- *
- * Return 0 if succeed otherwise -errno
- */
-int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path, uint32_t u_plen,
-                          struct dt_device_node **node);
-
 /**
  * dt_get_parent - Get a node's parent if any
  * @node: Node to get parent
-- 
2.34.1




 


Rackspace

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