|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] xen/arm: vpl011: record the virq only once it is reserved
On Mon, 16 Nov 2026, Orzel, Michal wrote:
> On 14-Nov-26 03:00, Stefano Stabellini wrote:
> > 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.
> Who is the other user here? The virq is either GUEST_VPL011_SPI or the
> Xen UART IRQ. libxl rejects a passthrough IRQ that matches the vpl011
> SPI, dom0less reserves the vpl011 virq before passthrough and panics
> on failure, and the Xen UART cannot be assigned. AFAICT there is no issue as
> of
> today and this should be explained in the commit msg.
Yes, I can explain this in the commit message.
Just one note though: Xen itself doesn't enforce it.
XEN_DOMCTL_bind_pt_irq accepts GUEST_VPL011_SPI. A toolstack that binds
a passthrough IRQ there before XEN_DOMCTL_vuart_op would see the vpl011
error path free that passthrough virq. I'll explain this in the commit
message.
> > Record the virq only after the reservation succeeds.
> >
> > Fixes: 08bbc1c02d38 ("xen/arm: vpl011: Fix domain_vpl011_init error path")
> The SHA is wrong - unknown revision. That said, I think this should be
> 1ee1e4b0d1ff instead.
Thanks! I can use that
---
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>
---
Changes in v2:
- explain in the commit message why libxl and dom0less never hit
this, and that Xen itself does not enforce it
- Fixes: tag now points to 1ee1e4b0d1ff
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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |