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

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



commit 85da01b713121495e8a6569514b09b4276dac7f3
Author:     Stefano Stabellini <sstabellini@xxxxxxxxxx>
AuthorDate: Wed Nov 18 16:35:42 2026 -0800
Commit:     Stefano Stabellini <stefano.stabellini@xxxxxxx>
CommitDate: Wed Nov 18 16:35:42 2026 -0800

    xen/arm: vpl011: record the virq only once it is reserved
    
    domain_vpl011_init() sets vpl011->virq before reserving it. If the
    reservation or the event channel allocation fails, the error path frees
    vpl011->virq, which the vPL011 never reserved.
    
    libxl and dom0less never hit this with a virq held by someone else, but
    Xen does not enforce it: XEN_DOMCTL_bind_pt_irq accepts
    GUEST_VPL011_SPI, so a passthrough IRQ bound there before
    XEN_DOMCTL_vuart_op would lose its reservation.
    
    Record the virq only after the reservation succeeds.
    
    Fixes: 1ee1e4b0d1ff ("xen/arm: Allow vpl011 to be used by DomU")
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx>
    Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
---
 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;
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

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