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

[PATCH v4 19/22] xen/arm: vIOMMU: Modify the partial device tree for dom0less


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Milan Djokic <milan_djokic@xxxxxxxx>
  • Date: Wed, 7 Oct 2026 00:07:18 +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=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=1QGjg9ezIGvEpFCVh2gO3DGpM70Awc+cA84nC1Wmbgc=; b=ejytKZBfbB2JW4x+WYIvAp9CucuFku0GFcimI3T985JFcEVWokutDaZIbWnyQVqWNvCHYHr4lEuwfeT672jO3c+BgJa2+QZBCcU3Vp8TcvdBAbJio2RZe0FxeQvNcDacpsnqkwav9KIPsyrUs+K7TBxWJzi+OQA81tfxToJkzEdnq+C3bWndYqVVZas74g01Wv7PLeW+q354+x+8SbGiG1EqKAf0bqT9Rg8DBEBL4qUPnq/XlrzVtIBcz0/l6X6t01459sxTJ07rjlkjbSoQxY8J07KQqV2JI25hvJ+mDCW8Dt+26n7dFHEh1n3u/7T8L2XwmYks5iJAvG4BPF6QZQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=b/B52BE2llkfVBCIIdyUKyD/CRJI2fJpIj1zdRnBgjCiJ7rBI14mdZ+V1oL7VuAkL5kpkzLSuzgXsQptHqGy5/LLDLELC8CatFx21evWl7lEJtEhIwWwhZpPSZZEPrhdaZJQWjCvD37sFj7PUbSvFhe14p6ZmOqwwOtP7DpYHwi1vAPlBq/g61Y3bO4hiwz52xdhDVMoPMN6dswCcVzaSNqJUN0kNaZvgWlofVuAlQ/IJRBL4oatAz/G06VCqSUhD7egFC5ML+eocsa0GxEo5VaSFpnu+1f7JDD5NtnFxqYzTQoJ9Doip0kSDPzcprSep37SlRLpxdxn8irkRoe4CQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Rahul Singh <rahul.singh@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Milan Djokic <milan_djokic@xxxxxxxx>
  • Delivery-date: Wed, 07 Oct 2026 00:07:26 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHdVe/RXw5lTx+Dsky6l5wgBOVJ2g==
  • Thread-topic: [PATCH v4 19/22] xen/arm: vIOMMU: Modify the partial device tree for dom0less

From: Rahul Singh <rahul.singh@xxxxxxx>

To configure IOMMU in guest for passthrough devices, user will need to
copy the unmodified "iommus" property from host device tree to partial
device tree. To enable the dom0 linux kernel to configure the IOMMU
correctly replace the phandle in partial device tree with virtual
IOMMU phandle when "iommus" property is set.

Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
Signed-off-by: Milan Djokic <milan_djokic@xxxxxxxx>
---
 xen/common/device-tree/dom0less-build.c | 40 ++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/xen/common/device-tree/dom0less-build.c 
b/xen/common/device-tree/dom0less-build.c
index fcbeb8adbd..7280bcf72b 100644
--- a/xen/common/device-tree/dom0less-build.c
+++ b/xen/common/device-tree/dom0less-build.c
@@ -331,7 +331,44 @@ static int __init handle_prop_pfdt(struct kernel_info 
*kinfo,
     return ( propoff != -FDT_ERR_NOTFOUND ) ? propoff : 0;
 }
 
-static int __init scan_pfdt_node(struct kernel_info *kinfo, const void *pfdt,
+#ifdef CONFIG_ARM_VIRTUAL_IOMMU
+static void __init modify_pfdt_node(void *pfdt, int nodeoff)
+{
+    int proplen, i, rc;
+    const fdt32_t *prop;
+    fdt32_t *prop_c;
+
+    prop = fdt_getprop(pfdt, nodeoff, "iommus", &proplen);
+    if ( !prop )
+        return;
+
+    prop_c = xzalloc_bytes(proplen);
+    if ( !prop_c )
+        return;
+
+    for ( i = 0; i < proplen / 8; ++i )
+    {
+        prop_c[i * 2] = cpu_to_fdt32(GUEST_PHANDLE_VSMMUV3);
+        prop_c[i * 2 + 1] = prop[i * 2 + 1];
+    }
+
+    rc = fdt_setprop(pfdt, nodeoff, "iommus", prop_c, proplen);
+    if ( rc )
+    {
+        dprintk(XENLOG_ERR, "Can't set the iommus property in partial FDT");
+        return;
+    }
+
+    return;
+}
+#else
+    static inline void __init modify_pfdt_node(void *pfdt, int nodeoff)
+    {
+        return;
+    }
+#endif
+
+static int __init scan_pfdt_node(struct kernel_info *kinfo, void *pfdt,
                                  int nodeoff,
                                  uint32_t address_cells, uint32_t size_cells,
                                  bool scan_passthrough_prop)
@@ -357,6 +394,7 @@ static int __init scan_pfdt_node(struct kernel_info *kinfo, 
const void *pfdt,
     node_next = fdt_first_subnode(pfdt, nodeoff);
     while ( node_next > 0 )
     {
+        modify_pfdt_node(pfdt, node_next);
         rc = scan_pfdt_node(kinfo, pfdt, node_next, address_cells, size_cells,
                             scan_passthrough_prop);
         if ( rc )
-- 
2.43.0

 


Rackspace

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