[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 07/23] xen/arm: vIOMMU: Add cmdline boot option "viommu = <string>"
- To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Milan Djokic <milan_djokic@xxxxxxxx>
- Date: Wed, 13 May 2026 11:40:18 +0200
- 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=MV/sq1dch9FW6vA4MHXb6hzqxYAXOLEG0PRlqFeD7yE=; b=cFnYMV5baXGAWeyK1sCX7vz3HltZhAyZxcA9BVBwKTtBG0j4YmiE/Z5rFtMt2fFBw2Varb/QrKmeEh/6lJpiBaJgev7VCcEMacNIBKBkS4d2YiNMTLVbJq2ogGkGbe53MhtJm9kWi37PLAq/6TaIxnuXYHP8MKzgncpPMCTZEKddrm/Tmtf7OhlQubehPVDuuetJE56FoFPiSqt5hmnyZLUomHy9uAxNiWUEGclopsuRJkSgX7CYrRwBmx4PXtmHJavFQLkPXnwBvHdhz3vT1jvRWz8fECohMGpfBOubiWHJk+VIl21wi1d7RiVZQTmsOrLucSBnFAnzT9JJreYrtg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=C6S3nud66yOErQNUBeZ7qVpZaGTHfyYv+A8Gzpb0DyuF4ogGLH6Y8/EAf5wUjC+sJBMViFY56Y774s9pmNO1Q4vB7NtB/C6QV8Y5oWTcsSr2itJD4DbsGjK3C5/oxFFNgAyVfeAA9+cXA+R5UWIFkyNGuId87T6Lyum3AJWWOtCLcslRhS4SnaDvlaxO0q/DWY0vtZm7MlPWv69DWRuWhkUudIgBKKVlCkiaPrPUZpk2eeJAZQ7ZP8ihrdL1xrukM4SVXDkMvvfl1mtddJKhvAlbMIlTatRPbp0Ejey2YftTkXi2B4EiFmVBA277RmnmiAvHN4SKf6IHfOVQAMwPwQ==
- 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>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Delivery-date: Wed, 13 May 2026 09:40:38 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Hi Julien,
On 4/14/26 09:18, Julien Grall wrote:
Hi Milan,
On 31/03/2026 10:52, Milan Djokic wrote:
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).
In Xen terminology, 'guests' refers to domUs. IOW, this doesn't include
dom0. Is this what you meant? If so, how would you enable it for dom0?
This boot option enables vIOMMU initialization in Xen itself and also
enables vIOMMU for dom0. For domUs, vIOMMU is enabled via the guest
configuration file.
The exception is dom0less mode, where setting this boot option enables
vIOMMU for all guests.
That said, is there any particular reason why this can't be
automatically enabled based on the SMMUv3 discovered?
This boot option was intended to provide a runtime enable/disable
mechanism for vIOMMU even when the vIOMMU build options
(CONFIG_VIRTUAL_IOMMU / CONFIG_VIRTUAL_ARM_SMMU_V3) are enabled.
However, this may be unnecessary, and relying on the build options for
enabling vIOMMU seems sufficient. I will remove this commit from the
patch series.
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 6c77129732..6531c2355c 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -2850,6 +2850,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 2a6742de73..ed338fe0ec 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)
Regardless what Luca wrote, why do we need to force "always_inline"?
I don't think it's necessary to use always_inline here, anyway this
function will be removed.
+{
+ /* 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_ARM_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() )
This is likely going to go wrong in the future if we add support for
other vIOMMU in the future. If we decide to continue using the command
line option (see above), you would want want an helper to return the
selected emulation and check against SMMUv3 here.
Yes, I will remove the command-line option and use the viommu_get_type()
helper where needed to check the selected vIOMMU emulation type.
Cheers,
Best regards,
Milan
|