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

[PATCH] xen/arm: vpl011: reserve the virq before setting up the backend


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stefano Stabellini <stefano.stabellini@xxxxxxx>
  • Date: Thu, 19 Nov 2026 13:37:22 -0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=E3EnGaPxpd0s9M8e/84KgfRDiKt9nPjVP0H5T44Ih1Y=; b=SqdVFATTbUt+2HMN/RG1Cq0rL+q68i7l68Go0ZQYg6numW/meF5QHnJYtCbOWHxNcxydJ8RV27SLaCYUtF0+4gnwZLfQdo+RpGM7UhUHw3kcE354+r9o9H2REVg+JW3VAO8YeR1w89lZPlSTpssqtMSqHhVRVBt8rUQ0TXyA6IPqVkPu+bYhZNka2nydOeiBVJwAC4F4DSqU+dfFdP7Xzf6C+rcZZWtq2Uoy6ZmuAX5BdvLZJhoam2+7X4aprvW71WtjZ12Fg9F99exss/OoZRhbxTiVI+a8hmJU6Jpmenxu/Qj62Vb3tam1211OxQrdtvJLQBiy7PZ8Y3EZ2e9BpA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WATBm+6k/H5aOOpiYP1SWldSTE4GV2weRFiZre4svoYx2fnl+0MQtwhGqz79PEW3A9r8+H3MmWhQAtP9M9p6ni6bClTNNRHmjfJ22L9WOGWFsaXN8G8F6++g89M3HVp74F+MMtzFNH/delUtQ+ehsfp6xP8jM+KjafY9IiIjSPmkSJq8BJaierLpOr1ZQ4BppRnCzizdV3sDKHCUZi7meCen6MT63DE82VC2eoNun88KJCHI1rbQxdCN4CW2GBj6tfCVLA9Hpf48EvKfXHXGtr3QwPkBNMXTLvAduxnizsg//wXS91HEGPP6cERbt8VawA4s5dCntcbszLS7cL0Mnw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Cc: <stefano.stabellini@xxxxxxx>, Julien Grall <julien@xxxxxxx>, "Bertrand Marquis" <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Thu, 19 Nov 2026 21:37:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

domain_vpl011_init() allocates the backend event channel before it
reserves the virq and records it in vpl011->virq. A notification sent
on that port in between runs vpl011_update_interrupt_status() with
vpl011->virq still 0. With CONFIG_NEW_VGIC this calls
vgic_inject_irq(d, NULL, 0, ...), and vgic_get_irq() dereferences the
NULL vcpu to look up the private interrupt 0. The same notification
also takes vpl011->lock and updates vpl011->uartfr before either is
initialised, and both are then reset under it.

Reserve and record the virq, set the initial flags and initialise the
lock first, before any backend is set up, so that they are valid by the
time the event channel exists. All the failures after the reservation
now go through domain_vpl011_deinit(), which releases the virq.

Fixes: ca0637a147af ("xen/arm: vpl011: Add SBSA UART emulation in Xen")
Fixes: 85da01b71312 ("xen/arm: vpl011: record the virq only once it is 
reserved")
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx>
---
CC: Julien Grall <julien@xxxxxxx>,
CC: Bertrand Marquis <bertrand.marquis@xxxxxxx>,
CC: Michal Orzel <michal.orzel@xxxxxxx>,
CC: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>

 xen/arch/arm/vpl011.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c
index a37e88a8b4..b1d286e1d1 100644
--- a/xen/arch/arm/vpl011.c
+++ b/xen/arch/arm/vpl011.c
@@ -689,6 +689,14 @@ int domain_vpl011_init(struct domain *d, struct 
vpl011_init_info *info)
         virq = GUEST_VPL011_SPI;
     }
 
+    if ( !vgic_reserve_virq(d, virq) )
+        return -EINVAL;
+    vpl011->virq = virq;
+
+    vpl011->uartfr = TXFE | RXFE;
+
+    spin_lock_init(&vpl011->lock);
+
     /*
      * info is NULL when the backend is in Xen.
      * info is != NULL when the backend is in a domain.
@@ -708,7 +716,7 @@ int domain_vpl011_init(struct domain *d, struct 
vpl011_init_info *info)
         rc = alloc_unbound_xen_event_channel(d, 0, info->console_domid,
                                              vpl011_notification);
         if ( rc < 0 )
-            goto out1;
+            goto out;
 
         vpl011->evtchn = info->evtchn = rc;
     }
@@ -725,26 +733,14 @@ int domain_vpl011_init(struct domain *d, struct 
vpl011_init_info *info)
         }
     }
 
-    if ( !vgic_reserve_virq(d, virq) )
-    {
-        rc = -EINVAL;
-        goto out1;
-    }
-    vpl011->virq = virq;
-
-    vpl011->uartfr = TXFE | RXFE;
-
-    spin_lock_init(&vpl011->lock);
-
     register_mmio_handler(d, &vpl011_mmio_handler,
                           vpl011->base_addr, GUEST_PL011_SIZE, NULL);
 
     return 0;
 
-out1:
+out:
     domain_vpl011_deinit(d);
 
-out:
     return rc;
 }
 
-- 
2.47.3




 


Rackspace

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