Skip to content

Commit b8291d6

Browse files
jandryukgregkh
authored andcommitted
xen/events: Update virq_to_irq on migration
[ Upstream commit 3fcc8e1 ] VIRQs come in 3 flavors, per-VPU, per-domain, and global, and the VIRQs are tracked in per-cpu virq_to_irq arrays. Per-domain and global VIRQs must be bound on CPU 0, and bind_virq_to_irq() sets the per_cpu virq_to_irq at registration time Later, the interrupt can migrate, and info->cpu is updated. When calling __unbind_from_irq(), the per-cpu virq_to_irq is cleared for a different cpu. If bind_virq_to_irq() is called again with CPU 0, the stale irq is returned. There won't be any irq_info for the irq, so things break. Make xen_rebind_evtchn_to_cpu() update the per_cpu virq_to_irq mappings to keep them update to date with the current cpu. This ensures the correct virq_to_irq is cleared in __unbind_from_irq(). Fixes: e46cdb6 ("xen: event channels") Cc: [email protected] Signed-off-by: Jason Andryuk <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Signed-off-by: Juergen Gross <[email protected]> Message-ID: <[email protected]> [ Adjust context ] Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent db62b1e commit b8291d6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/xen/events/events_base.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1807,9 +1807,20 @@ static int xen_rebind_evtchn_to_cpu(struct irq_info *info, unsigned int tcpu)
18071807
* virq or IPI channel, which don't actually need to be rebound. Ignore
18081808
* it, but don't do the xenlinux-level rebind in that case.
18091809
*/
1810-
if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0)
1810+
if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0) {
1811+
int old_cpu = info->cpu;
1812+
18111813
bind_evtchn_to_cpu(evtchn, tcpu, false);
18121814

1815+
if (info->type == IRQT_VIRQ) {
1816+
int virq = info->u.virq;
1817+
int irq = per_cpu(virq_to_irq, old_cpu)[virq];
1818+
1819+
per_cpu(virq_to_irq, old_cpu)[virq] = -1;
1820+
per_cpu(virq_to_irq, tcpu)[virq] = irq;
1821+
}
1822+
}
1823+
18131824
do_unmask(info, EVT_MASK_REASON_TEMPORARY);
18141825

18151826
return 0;

0 commit comments

Comments
 (0)