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

Re: [PATCH v3 17/23] xen/arm: vsmmuv3: Alloc virq for virtual SMMUv3


  • To: Milan Djokic <milan_djokic@xxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Mon, 13 Apr 2026 14:08:43 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=epam.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=uz9UpjxAqS+7cm/kak0fgHeEiA61zv4+UV3DbjBj2JA=; b=QSoLGjOqZdhVkSFdFrbgmXu9hE33Wpx8JFeKhauIipWssiUnhZvGOSgHCqXcYB/9UPCBNfes32oxNIhS8ytmoU6B17/w496jFYWkbi3TA/bH2qXMyG4Vsx1rOqabe0zVbgqpun3ziifGy6qI+iAwoVNaJ6zGkya3i0WQd84bntyry5pg99nT28qHLSJmYyLBKzBWWiuRfGLsq999KyWxKT5V505SZgJzRWpGLs0RvnefxeQ+TIFVeiieqzwmCWWYaF/81lUqXSPCqBqq2RzfiB+UKXSqKP2bWzcmeJvu7g00JDhnhCbxGzJ4hiqAvuI3gHoPjtYv5QMHFT9eGI3Izg==
  • 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=uz9UpjxAqS+7cm/kak0fgHeEiA61zv4+UV3DbjBj2JA=; b=G5Et4hkIqq+4+ku3/3Cb6zYS7UICCYWYvssjGKdV7GU+qpwJD2SgAyeV0dQx+E5Sl9ztFmaIRRl/8uY8+mrc/IxMVFCkV/k2NgKXp3qdnMoQXEKFWIjJfcc1PdkmASa5JzVTB5BIorIj0V+Y6+PX8UlL8kfZ8dRDZGAFjvtvUPiMDt/ATu+WHTwL8UFdre9EopzENm6QtTpJ7OaHAM3uxhq3CxHsvW4GgpQ4IovIQ06gzofPG1NJz+9VfXQaYBEf5Bto4Lgp9qYViIRlJpJnwsIMW7RD/zK/n+ciIWuc/AsQJGJE3W8XfLW2AJlPCq32+a/bpkPhyDg+9Te+DqhZ5Q==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=qposFM5KButqIHk3UZcHz56rIDo1oE8U1GMEheNs/05sz3//1e7ONfF4sWxCS+06uITnfmT8NEoxmMptY3wwlYYKsuWKq0DzgP0APn/VERGwBIAkvKuWveSNInyzTv1HrlDXF1nfIzIRWpFqIvQPbBWZfvuCmW0hw9earFUH1AjthjA3Q+K5WAs1/kgU2f3Kj++ZASqEo3sMWCCx3wx2ZMdJW8ZEeKONoN2a52NRbIR33mzeZfXdDrfGw5yppZRfQOWk3Hez9tir7mCNIEPa57ZxL/DeMZsxGQDbXr/2SWS3F1zdlNKEG48NZlFRN9s+wctN9QK1DpYvsCI7pleLxQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=X4EVDDE9qx75xFX397Ppf/syiLOdWFgtFZMLkEtperpBILjK+/S5eBIr6s/e8LO0/edR60Z8mXVveSuqhAhrM6/nqSfKixopoLZvHfnqOcsnmDsH1UqX2BsxipbrHMXPi5KZBRFIpPxYkzUfuvnNQbRZyXZSYgdU4YGeDBG4PS2lTyx2Lts7PEkz9RbPiq4BiKYMIIpLs2OP9ainGYnsFJwMQW39tJdUmWOQwhMMW80AVKVO1RNeWmCjz4TvNbamKojH2eHuOD6R5kqGuVZevfhZelh1kW8lA4sBXwz2XukaCe4q8hfZd1t3nNwsCjAd1en4gZfp5nJjEdrQv3G6VA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Rahul Singh <Rahul.Singh@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 13 Apr 2026 14:10:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHcy08JvVB1cGPAx0GVSpi1e5g4zw==
  • Thread-topic: [PATCH v3 17/23] xen/arm: vsmmuv3: Alloc virq for virtual SMMUv3

Hi Milan,

> On 31 Mar 2026, at 02:52, Milan Djokic <milan_djokic@xxxxxxxx> wrote:
> 
> From: Rahul Singh <rahul.singh@xxxxxxx>
> 
> Alloc and reserve virq for event queue and global error to send event to
> guests. Also Modify the libxl to accomadate the new define virq.
> 
> Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
> Signed-off-by: Milan Djokic <milan_djokic@xxxxxxxx>
> ---
> tools/libs/light/libxl_arm.c           | 28 ++++++++++++++++++++++++--
> xen/arch/arm/dom0less-build.c          | 17 ++++++++++++++++
> xen/drivers/passthrough/arm/vsmmu-v3.c | 13 ++++++++++++
> 3 files changed, 56 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
> index eb879473f5..803c3b39b7 100644
> --- a/tools/libs/light/libxl_arm.c
> +++ b/tools/libs/light/libxl_arm.c
> @@ -86,8 +86,8 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
> {
>     uint32_t nr_spis = 0, cfg_nr_spis = d_config->b_info.arch_arm.nr_spis;
>     unsigned int i;
> -    uint32_t vuart_irq, virtio_irq = 0;
> -    bool vuart_enabled = false, virtio_enabled = false;
> +    uint32_t vuart_irq, virtio_irq = 0, vsmmu_irq = 0;
> +    bool vuart_enabled = false, virtio_enabled = false, vsmmu_enabled = 
> false;
>     uint64_t virtio_mmio_base = GUEST_VIRTIO_MMIO_BASE;
>     uint32_t virtio_mmio_irq = GUEST_VIRTIO_MMIO_SPI_FIRST;
>     int rc;
> @@ -102,6 +102,16 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
>         vuart_enabled = true;
>     }
> 
> +    /*
> +     * If smmuv3 viommu is enabled then increment the nr_spis to allow 
> allocation
> +     * of SPI VIRQ for VSMMU.
> +     */
> +    if (d_config->b_info.arch_arm.viommu_type == LIBXL_VIOMMU_TYPE_SMMUV3) {
> +        nr_spis += (GUEST_VSMMU_SPI - 32) + 1;
> +        vsmmu_irq = GUEST_VSMMU_SPI;
> +        vsmmu_enabled = true;
> +    }

Now we would inflate too much nr_spis if also vPL011 is present, I think this 
commit should
modify that part and this part in this way:

if (d_config->b_info.arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART) {
    nr_spis = max(nr_spis, GUEST_VPL011_SPI - 32 + 1);
    vuart_irq = GUEST_VPL011_SPI;
    vuart_enabled = true;
}

if (d_config->b_info.arch_arm.viommu_type == LIBXL_VIOMMU_TYPE_SMMUV3) {
    nr_spis = max(nr_spis, GUEST_VSMMU_SPI - 32 + 1);
    vsmmu_irq = GUEST_VSMMU_SPI;
    vsmmu_enabled = true;
}

as done here 
https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libs/light/libxl_arm.c;h=7e9f8a1bc3666ac9a3f8aa487366399dc255b149;hb=refs/heads/staging#l144


> +
>     for (i = 0; i < d_config->num_disks; i++) {
>         libxl_device_disk *disk = &d_config->disks[i];
> 
> @@ -170,6 +180,11 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
>             return ERROR_FAIL;
>         }
> 
> +        if (vsmmu_enabled && irq == vsmmu_irq) {
> +            LOG(ERROR, "Physical IRQ %u conflicting with vSMMUv3 SPI\n", 
> irq);
> +            return ERROR_FAIL;
> +        }
> +
>         if (irq < 32)
>             continue;
> 
> @@ -907,6 +922,7 @@ static int make_vsmmuv3_node(libxl__gc *gc, void *fdt,
> {
>     int res;
>     const char *name = GCSPRINTF("iommu@%llx", GUEST_VSMMUV3_BASE);
> +    gic_interrupt intr;
> 
>     res = fdt_begin_node(fdt, name);
>     if (res) return res;
> @@ -925,6 +941,14 @@ static int make_vsmmuv3_node(libxl__gc *gc, void *fdt,
>     res = fdt_property_cell(fdt, "#iommu-cells", 1);
>     if (res) return res;
> 
> +    res = fdt_property_string(fdt, "interrupt-names", "combined");
> +    if (res) return res;
> +
> +    set_interrupt(intr, GUEST_VSMMU_SPI, 0xf, DT_IRQ_TYPE_LEVEL_HIGH);
> +
> +    res = fdt_property_interrupts(gc, fdt, &intr, 1);
> +    if (res) return res;
> +
>     res = fdt_end_node(fdt);
>     if (res) return res;
> 
> diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c
> index a48edb9568..7380753fa2 100644
> --- a/xen/arch/arm/dom0less-build.c
> +++ b/xen/arch/arm/dom0less-build.c
> @@ -225,6 +225,7 @@ static int __init make_vsmmuv3_node(const struct 
> kernel_info *kinfo)
>     char buf[24];
>     __be32 reg[GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS];
>     __be32 *cells;
> +    gic_interrupt_t intr;
>     void *fdt = kinfo->fdt;
> 
>     snprintf(buf, sizeof(buf), "iommu@%llx", GUEST_VSMMUV3_BASE);
> @@ -255,6 +256,22 @@ static int __init make_vsmmuv3_node(const struct 
> kernel_info *kinfo)
>     if ( res )
>         return res;
> 
> +    res = fdt_property_string(fdt, "interrupt-names", "combined");
> +    if ( res )
> +        return res;
> +
> +    set_interrupt(intr, GUEST_VSMMU_SPI, 0xf, DT_IRQ_TYPE_LEVEL_HIGH);
> +
> +    res = fdt_property(kinfo->fdt, "interrupts",
> +                       intr, sizeof(intr));
> +    if ( res )
> +        return res;
> +
> +    res = fdt_property_cell(kinfo->fdt, "interrupt-parent",
> +                            kinfo->phandle_intc);
> +    if ( res )
> +        return res;
> +
>     res = fdt_end_node(fdt);
> 
>     return res;
> diff --git a/xen/drivers/passthrough/arm/vsmmu-v3.c 
> b/xen/drivers/passthrough/arm/vsmmu-v3.c
> index 7a6c18df53..a5b9700369 100644
> --- a/xen/drivers/passthrough/arm/vsmmu-v3.c
> +++ b/xen/drivers/passthrough/arm/vsmmu-v3.c
> @@ -733,6 +733,7 @@ static const struct mmio_handler_ops vsmmuv3_mmio_handler 
> = {
> static int vsmmuv3_init_single(struct domain *d, paddr_t addr,
>                                paddr_t size, uint32_t virq)
> {
> +    int ret;
>     struct virt_smmu *smmu;
> 
>     smmu = xzalloc(struct virt_smmu);
> @@ -748,12 +749,24 @@ static int vsmmuv3_init_single(struct domain *d, 
> paddr_t addr,
> 
>     spin_lock_init(&smmu->cmd_queue_lock);
> 
> +    ret = vgic_reserve_virq(d, virq);
> +    if ( !ret )
> +    {
> +        ret = -EINVAL;
> +        goto out;
> +    }
> +
>     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;
> +
> +out:
> +    xfree(smmu);
> +    vgic_free_virq(d, virq);

I don’t think we should use vgic_free_virq here, if it was reserved already 
there is some
bug, the virq can be GUEST_VSMMU_SPI for guests and hw_iommu->irq for HW domain,
so if it’s reserved it should be a configuration issue and freeing it would 
remove “someone else”
reserved irq.
Probably I would print something in the if above and also I would just have the 
content of this
Label-path inside the if branch, since it is the only consumer of this label.

> +    return ret;
> }
> 
> int domain_vsmmuv3_init(struct domain *d)
> 

Cheers,
Luca




 


Rackspace

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