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

[PATCH v5 06/22] tools: Add XEN_DOMCTL_CONFIG_VIOMMU_* and viommu config param


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Milan Djokic <milan_djokic@xxxxxxxx>
  • Date: Tue, 3 Nov 2026 17:30:24 +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=h65T3qN5ENkSABqnFxXdapmONsngVT2rHLs98PX3ddU=; b=ahkik0El3DTnwq2VaEFtBcdLaUzM51tKW5lUmWBhIo8pFSOFk7OwQlWgy3OmX3UiSomex5ZsyJmbf5BjPy01HcC+VVDSTK2GRnEpwi21EyeqNLqXhdvSPdoRowzsNHfdZ0dgYA6VIOn0JW4rX8MPVj+pkepMf234lqy73XRS1ZqAif2bdtMI918JWNIgHwUlmjezVnCK128+VhQboSyFiCtt7XQ4bydRVTm65qPLlcmp6FvD/E4wT4jdvJl5MQV9VRsiqDn/aoL6fNA2gfImzGLB3zMJFhn0v11k7wsQKkPYbMohZKL0bAMXLEgEBjnbIPWLjptTIir+wLIsQ9eUkg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=E3vG1bBF3N1moRGwqk2e9wvs1j+o0/y05/WY/t10iTTzCXmhCcJ49tM3pL49jVFGH/YVpl3QIfJa240/tFC0NJT9FZEzsjJd8/bdeJNrztqXpHEUtiv18e2xLqvba2sBxdF7XgPmExtAX3kZ0k0KPQaoTyKrRWFJ0DG1lBPaGWJVYSIu1SUbG0q7FUOK7f8q8iuNxJ9RTA+Zf2KTlWRa39oKiiKxlq89CNpN04Q4LQMjFoZ/prrNVzYMXQKcekoko+OtT6zayw5VptfNnP+LqKY3ZZyaHSlAhi4td5g36vfDoBg2lkdfVrci6aCB7ZpbKAhg00Dt6jymAfR3qZtkcQ==
  • 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>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Nick Rosbrook <enr0n@xxxxxxxxxx>, George Dunlap <gwd@xxxxxxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Milan Djokic <milan_djokic@xxxxxxxx>
  • Delivery-date: Tue, 03 Nov 2026 17:30:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHda7kC/hJHclJuGkWXi0K+IS/7rA==
  • Thread-topic: [PATCH v5 06/22] tools: Add XEN_DOMCTL_CONFIG_VIOMMU_* and viommu config param

From: Rahul Singh <rahul.singh@xxxxxxx>

Add new viommu_type field and field values XEN_DOMCTL_CONFIG_VIOMMU_NONE
XEN_DOMCTL_CONFIG_VIOMMU_SMMUV3 in xen_arch_domainconfig to
enable/disable vIOMMU support for domains.

Also add viommu="N" parameter to xl domain configuration to enable the
vIOMMU for the domains. Currently, only the "smmuv3" type is supported
for ARM.

Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
Signed-off-by: Milan Djokic <milan_djokic@xxxxxxxx>
Acked-by: Nick Rosbrook <enr0n@xxxxxxxxxx>
---
 docs/man/xl.cfg.5.pod.in             | 22 ++++++++++++++++++++++
 tools/golang/xenlight/helpers.gen.go |  2 ++
 tools/golang/xenlight/types.gen.go   |  7 +++++++
 tools/include/libxl.h                |  5 +++++
 tools/libs/light/libxl_arm.c         | 13 +++++++++++++
 tools/libs/light/libxl_types.idl     |  6 ++++++
 tools/xl/xl_parse.c                  |  9 +++++++++
 7 files changed, 64 insertions(+)

diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
index b19c25c8d1..3920911033 100644
--- a/docs/man/xl.cfg.5.pod.in
+++ b/docs/man/xl.cfg.5.pod.in
@@ -3190,6 +3190,28 @@ option.
 
 =back
 
+=over 4
+
+=item B<viommu="STRING">
+
+Enable an emulated IOMMU for the guest, allowing the guest to configure
+IOMMU stage-1 translation for guest-assigned devices protected by the
+IOMMU.
+
+To enable the emulated IOMMU, specify the following option in the VM
+configuration file:
+
+viommu = "smmuv3"
+
+Currently, only the "smmuv3" type is supported on ARM.
+
+For this option to take effect, the passthrough option must also be
+enabled. E.g. if passthrough is explicitly disabled, or implicitly when no
+devices passed through to the guest while the vIOMMU is enabled, the
+domain configuration is invalid and will be refused by Xen.
+
+=back
+
 =head3 x86
 
 =over 4
diff --git a/tools/golang/xenlight/helpers.gen.go 
b/tools/golang/xenlight/helpers.gen.go
index 6ab23a708f..254e040802 100644
--- a/tools/golang/xenlight/helpers.gen.go
+++ b/tools/golang/xenlight/helpers.gen.go
@@ -1273,6 +1273,7 @@ x.ArchArm.NrSpis = uint32(xc.arch_arm.nr_spis)
 if err := x.ArchArm.ArmSci.fromC(&xc.arch_arm.arm_sci);err != nil {
 return fmt.Errorf("converting field ArchArm.ArmSci: %v", err)
 }
+x.ArchArm.ViommuType = ViommuType(xc.arch_arm.viommu_type)
 if err := x.ArchX86.MsrRelaxed.fromC(&xc.arch_x86.msr_relaxed);err != nil {
 return fmt.Errorf("converting field ArchX86.MsrRelaxed: %v", err)
 }
@@ -1815,6 +1816,7 @@ xc.arch_arm.nr_spis = C.uint32_t(x.ArchArm.NrSpis)
 if err := x.ArchArm.ArmSci.toC(&xc.arch_arm.arm_sci); err != nil {
 return fmt.Errorf("converting field ArchArm.ArmSci: %v", err)
 }
+xc.arch_arm.viommu_type = C.libxl_viommu_type(x.ArchArm.ViommuType)
 if err := x.ArchX86.MsrRelaxed.toC(&xc.arch_x86.msr_relaxed); err != nil {
 return fmt.Errorf("converting field ArchX86.MsrRelaxed: %v", err)
 }
diff --git a/tools/golang/xenlight/types.gen.go 
b/tools/golang/xenlight/types.gen.go
index 39bf9962d1..112b2825da 100644
--- a/tools/golang/xenlight/types.gen.go
+++ b/tools/golang/xenlight/types.gen.go
@@ -531,6 +531,12 @@ type ArmSci struct {
 Type ArmSciType
 }
 
+type ViommuType int
+const(
+ViommuTypeNone ViommuType = 0
+ViommuTypeSmmuv3 ViommuType = 1
+)
+
 type RdmReserve struct {
 Strategy RdmReserveStrategy
 Policy RdmReservePolicy
@@ -620,6 +626,7 @@ Vuart VuartType
 SveVl SveType
 NrSpis uint32
 ArmSci ArmSci
+ViommuType ViommuType
 }
 ArchX86 struct {
 MsrRelaxed Defbool
diff --git a/tools/include/libxl.h b/tools/include/libxl.h
index d294fb36bd..4ffbaba179 100644
--- a/tools/include/libxl.h
+++ b/tools/include/libxl.h
@@ -326,6 +326,11 @@
  */
 #define LIBXL_HAVE_BUILDINFO_ARCH_ARM_SCI 1
 
+/*
+ * libxl_domain_build_info has the arch_arm.viommu_type field.
+ */
+#define LIBXL_HAVE_BUILDINFO_ARCH_ARM_VIOMMU 1
+
 /*
  * LIBXL_HAVE_SOFT_RESET indicates that libxl supports performing
  * 'soft reset' for domains and there is 'soft_reset' shutdown reason
diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
index 47b662ea5c..7f1adfd79b 100644
--- a/tools/libs/light/libxl_arm.c
+++ b/tools/libs/light/libxl_arm.c
@@ -244,6 +244,19 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
     }
     LOG(DEBUG, " - SCI type=%u", config->arch.arm_sci_type);
 
+    switch (d_config->b_info.arch_arm.viommu_type) {
+    case LIBXL_VIOMMU_TYPE_NONE:
+        config->arch.viommu_type = XEN_DOMCTL_CONFIG_VIOMMU_NONE;
+        break;
+    case LIBXL_VIOMMU_TYPE_SMMUV3:
+        config->arch.viommu_type = XEN_DOMCTL_CONFIG_VIOMMU_SMMUV3;
+        break;
+    default:
+        LOG(ERROR, "Unknown vIOMMU type %d",
+            d_config->b_info.arch_arm.viommu_type);
+        return ERROR_FAIL;
+    }
+
     return 0;
 }
 
diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_types.idl
index ce697303b6..a585d24964 100644
--- a/tools/libs/light/libxl_types.idl
+++ b/tools/libs/light/libxl_types.idl
@@ -562,6 +562,11 @@ libxl_arm_sci = Struct("arm_sci", [
     ("type", libxl_arm_sci_type),
     ])
 
+libxl_viommu_type = Enumeration("viommu_type", [
+    (0, "none"),
+    (1, "smmuv3")
+    ], init_val = "LIBXL_VIOMMU_TYPE_NONE")
+
 libxl_rdm_reserve = Struct("rdm_reserve", [
     ("strategy",    libxl_rdm_reserve_strategy),
     ("policy",      libxl_rdm_reserve_policy),
@@ -746,6 +751,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
                                ("sve_vl", libxl_sve_type),
                                ("nr_spis", uint32, {'init_val': 
'LIBXL_NR_SPIS_DEFAULT'}),
                                ("arm_sci", libxl_arm_sci),
+                               ("viommu_type", libxl_viommu_type),
                               ])),
     ("arch_x86", Struct(None, [("msr_relaxed", libxl_defbool),
                               ])),
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 0ccece3e8a..4e5bc84ca3 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -3080,6 +3080,15 @@ skip_usbdev:
         }
     }
 
+    if (!xlu_cfg_get_string (config, "viommu", &buf, 1)) {
+        e = libxl_viommu_type_from_string(buf, &b_info->arch_arm.viommu_type);
+        if (e) {
+            fprintf(stderr,
+                    "Unknown vIOMMU type \"%s\" specified\n", buf);
+            exit(-ERROR_FAIL);
+        }
+    }
+
     parse_vkb_list(config, d_config);
 
     d_config->virtios = NULL;
-- 
2.43.0



 


Rackspace

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