Skip to content

Commit 51c23bd

Browse files
committed
xen/evtchn: avoid WARN() when unbinding an event channel
When unbinding a user event channel, the related handler might be called a last time in case the kernel was built with CONFIG_DEBUG_SHIRQ. This might cause a WARN() in the handler. Avoid that by adding an "unbinding" flag to struct user_event which will short circuit the handler. Fixes: 9e90e58 ("xen: evtchn: Allow shared registration of IRQ handers") Reported-by: Demi Marie Obenour <demi@invisiblethingslab.com> Tested-by: Demi Marie Obenour <demi@invisiblethingslab.com> Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> Link: https://lore.kernel.org/r/20240313071409.25913-2-jgross@suse.com Signed-off-by: Juergen Gross <jgross@suse.com>
1 parent 38620fc commit 51c23bd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/xen/evtchn.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ struct user_evtchn {
8585
struct per_user_data *user;
8686
evtchn_port_t port;
8787
bool enabled;
88+
bool unbinding;
8889
};
8990

9091
static void evtchn_free_ring(evtchn_port_t *ring)
@@ -164,6 +165,10 @@ static irqreturn_t evtchn_interrupt(int irq, void *data)
164165
struct per_user_data *u = evtchn->user;
165166
unsigned int prod, cons;
166167

168+
/* Handler might be called when tearing down the IRQ. */
169+
if (evtchn->unbinding)
170+
return IRQ_HANDLED;
171+
167172
WARN(!evtchn->enabled,
168173
"Interrupt for port %u, but apparently not enabled; per-user %p\n",
169174
evtchn->port, u);
@@ -421,6 +426,7 @@ static void evtchn_unbind_from_user(struct per_user_data *u,
421426

422427
BUG_ON(irq < 0);
423428

429+
evtchn->unbinding = true;
424430
unbind_from_irqhandler(irq, evtchn);
425431

426432
del_evtchn(u, evtchn);

0 commit comments

Comments
 (0)