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

Re: [PATCH v2 06/23] xen/domctl: Add XEN_DOMCTL_CONFIG_VIOMMU_* and viommu config param


  • To: Nick Rosbrook <enr0n@xxxxxxxxxx>
  • From: Milan Djokic <milan_djokic@xxxxxxxx>
  • Date: Thu, 26 Mar 2026 20:35:10 +0100
  • 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=NQDYybMQvCacvL5rb1fB8/Klqvp0bufgXnXFP6iNGlM=; b=nPa3tAKrgo34qSKAv9v/q3Fl9onDs0oEbt/mSzzbMlnNuLWrHTQuAhVGb5CNiocC58taZPoWqb6AATu7ZWYtXY7Mx8cAqP/Y6itrM1nBKlHFKh5mRnCB31dJY0MuQAAlt3ZRmXAAfif6SIMl1epZXYkKHwiDVa+qecAS0cOHpMj2svnZlp59j2QKdbc2FW7UF5di/TRH7vSTlUeG3bp4nYixyeGJnDtOdbZFbdCcIDPUA++MleIKuwa+rS4o+xIHITXyx90Horh5nKN7TnazkhRdxySMU4Gk1bGdrqr9YPpTLBZAPToMI+w9gjvxWOTfTMVr5L3CMKnT8Zed0D2yOg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fSRBJhs71sMJ6V5JvIJCqtyqpAAhcK/tP5wfgEDExJlSoTWMatpm/mcufYHcFe3+Vy21kjAGWbhM5JW8dG3L8pD8eBwOU81p0TnmF+Gl7aSL2NOgRXPZPtW2JNN/XtCwSJzeZ6S9bKR73Gco2aN1s4lC8+bBYnlDhN9taABFB0C4F8YfMjJ4WbO8xXZ2/TlqOOVfiir10C931f6dA056uVo9IxoV59rB2wzYvcKB/bbv1uY1kQibyVMhVjD5jgTqTpkrTrHxmsZ2QCPdgskSSRGzG5leb70FkYr1fjhRQvW9NV/qt4h9lhy1/PeFWw3VCfqD/jdE9InC1a6ebTujIQ==
  • 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: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, George Dunlap <gwd@xxxxxxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Thu, 26 Mar 2026 19:35:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 3/25/26 19:52, Nick Rosbrook wrote:
On Mon, Mar 23, 2026 at 6:51 PM Milan Djokic <milan_djokic@xxxxxxxx> wrote:

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>
---
  docs/man/xl.cfg.5.pod.in             | 13 +++++++++++++
  tools/golang/xenlight/helpers.gen.go |  2 ++
  tools/golang/xenlight/types.gen.go   |  1 +
  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, 49 insertions(+)

diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
index 27c455210b..f69cdee55c 100644
--- a/docs/man/xl.cfg.5.pod.in
+++ b/docs/man/xl.cfg.5.pod.in
@@ -3162,6 +3162,19 @@ option.

  =back

+=over 4
+
+=item B<viommu="N">
+
+To enable viommu, user must specify the following option in the VM
+config file:
+
+viommu = "smmuv3"
+
+Currently, only the "smmuv3" type is supported for ARM.
+
+=back
+
  =head3 x86

  =over 4
diff --git a/tools/golang/xenlight/helpers.gen.go 
b/tools/golang/xenlight/helpers.gen.go
index 8909fe8a1b..4f0997f02f 100644
--- a/tools/golang/xenlight/helpers.gen.go
+++ b/tools/golang/xenlight/helpers.gen.go
@@ -1195,6 +1195,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.Viommu = ViommuType(xc.arch_arm.viommu)
  if err := x.ArchX86.MsrRelaxed.fromC(&xc.arch_x86.msr_relaxed);err != nil {
  return fmt.Errorf("converting field ArchX86.MsrRelaxed: %v", err)
  }
@@ -1734,6 +1735,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 = C.libxl_viommu_type(x.ArchArm.Viommu)
  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 ab9d4ca7b4..8a37b52a82 100644
--- a/tools/golang/xenlight/types.gen.go
+++ b/tools/golang/xenlight/types.gen.go
@@ -610,6 +610,7 @@ Vuart VuartType
  SveVl SveType
  NrSpis uint32
  ArmSci ArmSci
+Viommu ViommuType
  }
  ArchX86 struct {
  MsrRelaxed Defbool

The generated go code doesn't look right - it appears to be missing a
definition for `ViommuType` and the associated constants for the
"viommu_type" Enumeration added to libxl_types.idl. Does the code need
re-generating?


Yes, I will re-generate the code in the updated version. Thanks for noticing.

diff --git a/tools/include/libxl.h b/tools/include/libxl.h
index bc35e412da..f7d5c77e23 100644
--- a/tools/include/libxl.h
+++ b/tools/include/libxl.h
@@ -318,6 +318,11 @@
   */
  #define LIBXL_HAVE_BUILDINFO_ARCH_ARM_SCI 1

+/*
+ * libxl_domain_build_info has the arch_arm.viommu_type field.
+ */
+#define LIBXL_HAVE_BUILDINFO_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 7e9f8a1bc3..a248793588 100644
--- a/tools/libs/light/libxl_arm.c
+++ b/tools/libs/light/libxl_arm.c
@@ -247,6 +247,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 d64a573ff3..c7ad0e77b2 100644
--- a/tools/libs/light/libxl_types.idl
+++ b/tools/libs/light/libxl_types.idl
@@ -561,6 +561,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),
@@ -736,6 +741,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 1a2ea8b5d5..dcae8314fe 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -3033,6 +3033,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

-Nick

BR,
Milan




 


Rackspace

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