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

[PATCH v2 07/23] xen/arm: vIOMMU: Add cmdline boot option "viommu = <string>"


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Milan Djokic <milan_djokic@xxxxxxxx>
  • Date: Mon, 23 Mar 2026 22:51: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=Nd5qnmJ7Wh0r99wMI0fZEOIGXmYSQVC8hc9mmzhO4to=; b=R9Oxdn6J1AksGJ3iEOItzNY0P1tJnU7bu7XCDUDl+JNWfnikOWazucDjR18OKyK5lsFKBf8Je58xeFvjxCIEjbDpaxWvU8GiUkgrjpaWYCztev1Pae/FhfwTzeX5TuWKdf2WlUDYNOvgrcc2u7Vz0nBH+Od+O3+N0+wQAAut30Dq7mDAWYu9xgmEzu3RJfd42luVGtb6Se34URckvtbUIwEmd9do/n2SeYMeo5BiRdOe870z227G7zkg8Nl5aOs1F46tmqCU9+UdzzwfRtul7XDkyHf8E0zEqyrza+lA4ATMsZj86rhcplRiZpg33bGPdgqlU2Oy9F/fHIIHCDVpvg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EV5jU6WPfhKfedu+pKtqoEO2cZ2z3nY3nEjSVP2Rto5tcnLY/DpxRaliCwiVUdaryY6nT9BWGufwczgDe9VVsvxuX9ns1PlmtL65pdSmB0y3/eXHHeZg4dS4zVPWt42fWS1iXqIIqKxyhnyJw+LHv5NvvfNDp14hmGViEdQaTJHPnqq2Cm2RYQrQWc0aT9MxCAiy2KMZxHwwS2i43kMYR56E3nNL89SRj+O0GuubPQbbMWGRIfa8gUyjC3mznF2UgAd+ErUGavmbIRZyfrT0iEy4njVs7AjlN/fvaOz/TdnC0JgCavR/n/aSUICyp9bHzbjrFjCI6InRsp0WAk+MDQ==
  • 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: Rahul Singh <rahul.singh@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Milan Djokic <milan_djokic@xxxxxxxx>
  • Delivery-date: Mon, 23 Mar 2026 22:51:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcuxeTokJK1XhSWEexAuBtof/9HQ==
  • Thread-topic: [PATCH v2 07/23] xen/arm: vIOMMU: Add cmdline boot option "viommu = <string>"

From: Rahul Singh <rahul.singh@xxxxxxx>

Add cmdline boot option "viommu = <string>" to enable or disable the
virtual iommu support for guests on ARM (only viommu="smmuv3" supported
for now).

Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
Signed-off-by: Milan Djokic <milan_djokic@xxxxxxxx>
---
 docs/misc/xen-command-line.pandoc      |  9 +++++++++
 xen/arch/arm/include/asm/viommu.h      | 12 ++++++++++++
 xen/drivers/passthrough/arm/viommu.c   | 11 +++++++++++
 xen/drivers/passthrough/arm/vsmmu-v3.c |  3 +++
 4 files changed, 35 insertions(+)

diff --git a/docs/misc/xen-command-line.pandoc 
b/docs/misc/xen-command-line.pandoc
index ebdca007d2..3a1cc562c4 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -2855,6 +2855,15 @@ The optional `keep` parameter causes Xen to continue 
using the vga
 console even after dom0 has been started.  The default behaviour is to
 relinquish control to dom0.
 
+### viommu (arm)
+> `= <string>`
+
+> Default: ``
+
+Flag to enable or disable support for the virtual IOMMU for guests. Disabled by
+default. Enable by specifying target IOMMU type (if supported). Only "smmuv3"
+IOMMU emulation supported at this point.
+
 ### viridian-spinlock-retry-count (x86)
 > `= <integer>`
 
diff --git a/xen/arch/arm/include/asm/viommu.h 
b/xen/arch/arm/include/asm/viommu.h
index 4785877e2a..811e9312d5 100644
--- a/xen/arch/arm/include/asm/viommu.h
+++ b/xen/arch/arm/include/asm/viommu.h
@@ -10,6 +10,7 @@
 #include <public/xen.h>
 
 extern struct list_head host_iommu_list;
+extern char viommu[];
 
 /* data structure for each hardware IOMMU */
 struct host_iommu {
@@ -50,6 +51,12 @@ uint16_t viommu_get_type(void);
 void add_to_host_iommu_list(paddr_t addr, paddr_t size,
                             const struct dt_device_node *node);
 
+static always_inline bool is_viommu_enabled(void)
+{
+    /* only smmuv3 emulation supported */
+    return !strcmp(viommu, "smmuv3");
+}
+
 #else
 
 static inline uint8_t viommu_get_type(void)
@@ -76,6 +83,11 @@ static inline void add_to_host_iommu_list(paddr_t addr, 
paddr_t size,
     return;
 }
 
+static always_inline bool is_viommu_enabled(void)
+{
+    return false;
+}
+
 #endif /* CONFIG_VIRTUAL_IOMMU */
 
 #endif /* __ARCH_ARM_VIOMMU_H__ */
diff --git a/xen/drivers/passthrough/arm/viommu.c 
b/xen/drivers/passthrough/arm/viommu.c
index 53ae46349a..5f5892fbb2 100644
--- a/xen/drivers/passthrough/arm/viommu.c
+++ b/xen/drivers/passthrough/arm/viommu.c
@@ -3,6 +3,7 @@
 #include <xen/errno.h>
 #include <xen/init.h>
 #include <xen/irq.h>
+#include <xen/param.h>
 #include <xen/types.h>
 
 #include <asm/viommu.h>
@@ -38,8 +39,18 @@ void add_to_host_iommu_list(paddr_t addr, paddr_t size,
     list_add_tail(&iommu_data->entry, &host_iommu_list);
 }
 
+/* By default viommu is disabled.
+ * If enabled, 'viommu' param indicates type (smmuv3 is only supported type 
atm)
+ */
+char __read_mostly viommu[10] = "";
+string_param("viommu", viommu);
+
 int domain_viommu_init(struct domain *d, uint16_t viommu_type)
 {
+    /* Enable viommu when it has been enabled explicitly (viommu="smmuv3"). */
+    if ( !is_viommu_enabled() )
+        return 0;
+
     if ( viommu_type == XEN_DOMCTL_CONFIG_VIOMMU_NONE )
         return 0;
 
diff --git a/xen/drivers/passthrough/arm/vsmmu-v3.c 
b/xen/drivers/passthrough/arm/vsmmu-v3.c
index 6b4009e5ef..e36f200ba5 100644
--- a/xen/drivers/passthrough/arm/vsmmu-v3.c
+++ b/xen/drivers/passthrough/arm/vsmmu-v3.c
@@ -105,6 +105,9 @@ void __init vsmmuv3_set_type(void)
 {
     const struct viommu_desc *desc = &vsmmuv3_desc;
 
+    if ( !is_viommu_enabled() )
+        return;
+
     if ( cur_viommu && (cur_viommu != desc) )
     {
         printk("WARNING: Cannot set vIOMMU, already set to a different 
value\n");
-- 
2.43.0



 


Rackspace

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