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

[PATCH 20/20] xen/arm: vIOMMU: Modify the partial device tree for dom0less


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Milan Djokic <milan_djokic@xxxxxxxx>
  • Date: Thu, 7 Aug 2025 16:59:35 +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=N139GbhE8zRhemLrZtoyLCg0r1ZmYt9NvxgUFa12HIU=; b=PwA70XNqIFG3T0Fji25/fV99Ffst+QIFy5HS4pQkBUSwaiuI9AwN3DVnUigzH/PXWHH56+K9dB5r0YN0u61e5RNsep3/bqrsKHY+OTJToxv72rODOg2T1conFSEgEmxJgUcc83+R9+OlL5jgbwkGoeCdjI0XQoLAC89gFKEB0CROtXEeLXSPhQYHqxgs3NVTgq9c9N4GecKDQVw7RROLbAwNSN5R6rujWPShect659AU7V5qiCvagmUscj3ksdYsSercP71/Utaeo5BFQv6tSkcv/oHkCdETIeJiWO47N8JQeHSGu2NAl13D+ZCf3aOulGNfHe8LLyq8Jsto1cODOA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=W0VhczSh8b1n66G6+pDtD4QUIJyDY4+65PQi18x6yY41CWARNwBCzyLbXbosyftaxIl44vV0D1mSXvBLB6aioVCguYDfB6UOdzC9Z6N65TFBOkpLQCEip3tXBW3mBNtiRmKLTdDbdC4IY5T4edxat+4JQpJA6JEoXir0LV9oadDuB7mWTbioPmJniBrApKHGojQx7cgdIvoLkbb24sA1N4BYSenlHWgta37sNbZWrVSYValkMqaGbjyhL9sRQCwXmSsAjeM4qTVILaR03l64QC19VEg1Jhi888KKMFSMlyJP5fTtrBwRwpko4cNAJx0RRJzMstIuumyyyCtRqr7qhw==
  • Authentication-results: 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: Thu, 07 Aug 2025 18:32:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcB7ynr3/KXhUzEkK9AiVwODSe+g==
  • Thread-topic: [PATCH 20/20] 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 confiure 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 | 31 ++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/xen/common/device-tree/dom0less-build.c 
b/xen/common/device-tree/dom0less-build.c
index 6bb038111d..3cfffa6581 100644
--- a/xen/common/device-tree/dom0less-build.c
+++ b/xen/common/device-tree/dom0less-build.c
@@ -314,7 +314,35 @@ 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,
+static void 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);
+
+    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;
+}
+
+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)
@@ -340,6 +368,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®.