|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] xen/arm: vpl011: reserve the virq before setting up the backend
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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |