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

[PATCH] xen/arm: vpl011: record the virq only once it is reserved


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stefano Stabellini <stefano.stabellini@xxxxxxx>
  • Date: Fri, 13 Nov 2026 18:00:40 -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=bixuWMLgXTssLvB67EoK9dbkSZ2/awug8YA4EzayTlI=; b=seMdApIO4wew5scb0cocdtLnq7D/WZicXNJMppvuwJD+X2vsX5a4rQTjAxn3XgiS2Vyjf/2b6dv5NFVLpx9watUPNIq2ZaRQqW0kYabv8QuPomVcafKNv5Ozxa/eE5mfCRh+x+Iql7w/dx400zg8lXKlLj3nP+efbuRj+1XmTf3mQSPa5303C18/EEeC6m1ZdFj7BvTyfypuSlhFBA2Bf260O/K0CXDMfvp94hDWQ4Xe+wj1v4qnic/TMPcV6fXlevFt6+KCIqF+v5APGNozyWO2htCzgpA6CTD9HInIzbUYpf/c5RVfxDfnEbV6SHQ2qnv4meyXFG6MJ5q7YV18vw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A3KBSLpxzbGiLenNLg/0yT7riNNWyrb2Qr1q7O4ZZyOXctdaYgkyvvoVM1jN6MjRPo8ckG3qhtWTXC3Sg7g0womWqhcOqnRL7NrLBW9EW2qBjrrO/LIKQIM1/Ax5Hqgj7BoPwC5PWFu9au45oD6g0uQznr+M9d+8dthqxr8OLit29RxYk+6PIhqiJKBWrU20QAQNfAlYIK01Pc2uYmFsVwXCE9Z6FICN1j8rkI95U2dJeKNZEvF0Fiy+yaUGQmbBsAsLvnbQFjeXZpk5TvAY4djXUyR9opZJ8B71ZVqQkK76oLP2cbPnThJwMLSF8lMx5plkkZFlOMcmHxgxLdSAAA==
  • 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>, 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: Sat, 14 Nov 2026 02:01:07 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

domain_vpl011_init() sets vpl011->virq before vgic_reserve_virq() claims
it, and both a refused reservation and a failed
alloc_unbound_xen_event_channel() take the out1 error path into
domain_vpl011_deinit(), which frees vpl011->virq. That clears the
allocation bit of an interrupt the vPL011 never reserved, so an
interrupt held by another user can be handed out a second time.

Record the virq only after the reservation succeeds.

Fixes: 08bbc1c02d38 ("xen/arm: vpl011: Fix domain_vpl011_init error path")
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx>
---
CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>,
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 | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c
index d0d17c76b7..a37e88a8b4 100644
--- a/xen/arch/arm/vpl011.c
+++ b/xen/arch/arm/vpl011.c
@@ -640,6 +640,7 @@ static void vpl011_notification(struct vcpu *v, unsigned 
int port)
 int domain_vpl011_init(struct domain *d, struct vpl011_init_info *info)
 {
     int rc;
+    unsigned int virq;
     struct vpl011 *vpl011 = &d->arch.vpl011;
 
     if ( vpl011->backend.dom.ring_buf )
@@ -659,7 +660,7 @@ int domain_vpl011_init(struct domain *d, struct 
vpl011_init_info *info)
         if ( (uart != NULL) && (vpl011_irq > 0) )
         {
             vpl011->base_addr = uart->base_addr;
-            vpl011->virq = vpl011_irq;
+            virq = vpl011_irq;
         }
         else
         {
@@ -685,7 +686,7 @@ int domain_vpl011_init(struct domain *d, struct 
vpl011_init_info *info)
     else
     {
         vpl011->base_addr = GUEST_PL011_BASE;
-        vpl011->virq = GUEST_VPL011_SPI;
+        virq = GUEST_VPL011_SPI;
     }
 
     /*
@@ -724,12 +725,12 @@ int domain_vpl011_init(struct domain *d, struct 
vpl011_init_info *info)
         }
     }
 
-    rc = vgic_reserve_virq(d, vpl011->virq);
-    if ( !rc )
+    if ( !vgic_reserve_virq(d, virq) )
     {
         rc = -EINVAL;
         goto out1;
     }
+    vpl011->virq = virq;
 
     vpl011->uartfr = TXFE | RXFE;
 
-- 
2.47.3




 


Rackspace

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