[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 05/23] xen/arm: vsmmuv3: Add dummy support for virtual SMMUv3 for guests
- To: Luca Fancellu <Luca.Fancellu@xxxxxxx>
- From: Milan Djokic <milan_djokic@xxxxxxxx>
- Date: Sun, 3 May 2026 13:04:55 +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=W0mlhXQDrnEd0jGP34J37YE6/XNOg5kxp8uDHpTU51M=; b=MjXeOST2jzPLQr+tZdAMVfwhn6Zj59ZRcmc5VnV9fYPK6OTTrv4z0QjH0OEPM21r0zcCYctjoFxl+owdNlPKFk+Rl9NH2+3/Vd7MSgM8yKEhmI0/Cg3hBkDAxF1IaPHfoKzJ2Emm3i/uWKArH/Ir0CurBVNZom0x80JsaNfNTWdD/HS+VRyjau/yYFwjzkNGTXdTbvbh3EN5xLjXDLGjp+RjiZkGGY6LcOKTCY2lJCCQjt05c8HiYL0MY9zbeme8ASEzmiNjKQHigNY/dPFRRA2g5FHs1K6CLsH7P8YlTeU6lDp+nc55emiW0m0GOCKhmjHqTE3fbfM6BFBIj4j4Bg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HsAENn8+C/70MlembmHeiCdPgwJpRofQmJIXpWmikOtpLGbxJ4cDvfRQ6v4nWXWijrCkvbK/kCX/azlud7zhzl1cNQNQCuQ61k9Irjqjzcn7vw9Fbh4MslI8NFGOwrysAA+xytNlRyPs7mp3NcG4wef35LRyj/cqwYdrzG21ySUocf0yF+XpAEvDvlpyOZfpWTl3Lsa9pEHYCnJF6x03Cm0uROc/s69aLirLNKYcVB9BXBaHxMdDfhUTuARc3PTS+SXXdPGSCv9jpcEXNXBA8TP27foI3Ao7I+yUCxxTAxhZxuWOGQ2d4encDRb0CYwewPxuBnL/G3Gy304CYawmzg==
- 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>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Delivery-date: Sun, 03 May 2026 11:05:10 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Hi Luca,
On 4/10/26 13:59, Luca Fancellu wrote:
Hi Milan,
diff --git a/xen/drivers/passthrough/arm/viommu.c
b/xen/drivers/passthrough/arm/viommu.c
index 7ab6061e34..53ae46349a 100644
--- a/xen/drivers/passthrough/arm/viommu.c
+++ b/xen/drivers/passthrough/arm/viommu.c
@@ -2,12 +2,42 @@
#include <xen/errno.h>
#include <xen/init.h>
+#include <xen/irq.h>
#include <xen/types.h>
#include <asm/viommu.h>
+/* List of all host IOMMUs */
+LIST_HEAD(host_iommu_list);
+
const struct viommu_desc __read_mostly *cur_viommu;
+/* Common function for adding to host_iommu_list */
+void add_to_host_iommu_list(paddr_t addr, paddr_t size,
+ const struct dt_device_node *node)
+{
+ struct host_iommu *iommu_data;
+
+ iommu_data = xzalloc(struct host_iommu);
+ if ( !iommu_data )
+ panic("vIOMMU: Cannot allocate memory for host IOMMU data\n");
+
+ iommu_data->addr = addr;
+ iommu_data->size = size;
+ iommu_data->dt_node = node;
+ iommu_data->irq = platform_get_irq(node, 0);
+ if ( iommu_data->irq < 0 )
+ {
+ gdprintk(XENLOG_ERR,
+ "vIOMMU: Cannot find a valid IOMMU irq\n");
We need to free iommu_data here
Yes, will fix this.
+ return;
+ }
+
+ printk("vIOMMU: Found IOMMU @0x%"PRIx64"\n", addr);
+
+ list_add_tail(&iommu_data->entry, &host_iommu_list);
+}
+
int domain_viommu_init(struct domain *d, uint16_t viommu_type)
{
if ( viommu_type == XEN_DOMCTL_CONFIG_VIOMMU_NONE )
diff --git a/xen/drivers/passthrough/arm/vsmmu-v3.c
b/xen/drivers/passthrough/arm/vsmmu-v3.c
new file mode 100644
index 0000000000..6b4009e5ef
--- /dev/null
+++ b/xen/drivers/passthrough/arm/vsmmu-v3.c
@@ -0,0 +1,124 @@
+/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */
+
+#include <xen/param.h>
+#include <xen/sched.h>
+#include <asm/mmio.h>
+#include <asm/viommu.h>
+
+/* Struct to hold the vIOMMU ops and vIOMMU type */
+extern const struct viommu_desc __read_mostly *cur_viommu;
+
+struct virt_smmu {
+ struct domain *d;
+ struct list_head viommu_list;
+};
+
+static int vsmmuv3_mmio_write(struct vcpu *v, mmio_info_t *info,
+ register_t r, void *priv)
+{
+ return IO_HANDLED;
+}
+
+static int vsmmuv3_mmio_read(struct vcpu *v, mmio_info_t *info,
+ register_t *r, void *priv)
+{
+ return IO_HANDLED;
If this has to be treated for now as RAZ, being a dummy implementation,
I would add *r = 0;
As suggested in later comments, I will insert BUG_ON("unimplemented")
for functions which are not complete at this point.
+}
+
+static const struct mmio_handler_ops vsmmuv3_mmio_handler = {
+ .read = vsmmuv3_mmio_read,
+ .write = vsmmuv3_mmio_write,
+};
+
+static int vsmmuv3_init_single(struct domain *d, paddr_t addr, paddr_t size)
+{
+ struct virt_smmu *smmu;
+
+ smmu = xzalloc(struct virt_smmu);
+ if ( !smmu )
+ return -ENOMEM;
+
+ smmu->d = d;
+
+ register_mmio_handler(d, &vsmmuv3_mmio_handler, addr, size, smmu);
+
+ /* Register the vIOMMU to be able to clean it up later. */
+ list_add_tail(&smmu->viommu_list, &d->arch.viommu_list);
+
+ return 0;
+}
+
+int domain_vsmmuv3_init(struct domain *d)
+{
+ int ret;
+ INIT_LIST_HEAD(&d->arch.viommu_list);
+
+ if ( is_hardware_domain(d) )
+ {
+ struct host_iommu *hw_iommu;
+
+ list_for_each_entry(hw_iommu, &host_iommu_list, entry)
+ {
+ ret = vsmmuv3_init_single(d, hw_iommu->addr, hw_iommu->size);
+ if ( ret )
+ return ret;
+ }
+ }
+ else
+ {
+ ret = vsmmuv3_init_single(d, GUEST_VSMMUV3_BASE, GUEST_VSMMUV3_SIZE);
+ if ( ret )
+ return ret;
+ }
+
+ return 0;
+}
+
+int vsmmuv3_relinquish_resources(struct domain *d)
+{
+ struct virt_smmu *pos, *temp;
+
+ /* Cope with unitialized vIOMMU */
Typo s/unitialized/uninitialized/
Cheers,
Luca
BR,
Milan
|