Commit bce5963b authored by Juergen Gross's avatar Juergen Gross

xen/events: fix binding user event channels to cpus

When binding an interdomain event channel to a vcpu via
IOCTL_EVTCHN_BIND_INTERDOMAIN not only the event channel needs to be
bound, but the affinity of the associated IRQi must be changed, too.
Otherwise the IRQ and the event channel won't be moved to another vcpu
in case the original vcpu they were bound to is going offline.

Cc: <stable@vger.kernel.org> # 4.13
Fixes: c48f64ab ("xen-evtchn: Bind dyn evtchn:qemu-dm interrupt to next online VCPU")
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
parent 9637d517
...@@ -1294,7 +1294,7 @@ void rebind_evtchn_irq(int evtchn, int irq) ...@@ -1294,7 +1294,7 @@ void rebind_evtchn_irq(int evtchn, int irq)
} }
/* Rebind an evtchn so that it gets delivered to a specific cpu */ /* Rebind an evtchn so that it gets delivered to a specific cpu */
int xen_rebind_evtchn_to_cpu(int evtchn, unsigned tcpu) static int xen_rebind_evtchn_to_cpu(int evtchn, unsigned int tcpu)
{ {
struct evtchn_bind_vcpu bind_vcpu; struct evtchn_bind_vcpu bind_vcpu;
int masked; int masked;
...@@ -1328,7 +1328,6 @@ int xen_rebind_evtchn_to_cpu(int evtchn, unsigned tcpu) ...@@ -1328,7 +1328,6 @@ int xen_rebind_evtchn_to_cpu(int evtchn, unsigned tcpu)
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(xen_rebind_evtchn_to_cpu);
static int set_affinity_irq(struct irq_data *data, const struct cpumask *dest, static int set_affinity_irq(struct irq_data *data, const struct cpumask *dest,
bool force) bool force)
...@@ -1342,6 +1341,15 @@ static int set_affinity_irq(struct irq_data *data, const struct cpumask *dest, ...@@ -1342,6 +1341,15 @@ static int set_affinity_irq(struct irq_data *data, const struct cpumask *dest,
return ret; return ret;
} }
/* To be called with desc->lock held. */
int xen_set_affinity_evtchn(struct irq_desc *desc, unsigned int tcpu)
{
struct irq_data *d = irq_desc_get_irq_data(desc);
return set_affinity_irq(d, cpumask_of(tcpu), false);
}
EXPORT_SYMBOL_GPL(xen_set_affinity_evtchn);
static void enable_dynirq(struct irq_data *data) static void enable_dynirq(struct irq_data *data)
{ {
int evtchn = evtchn_from_irq(data->irq); int evtchn = evtchn_from_irq(data->irq);
......
...@@ -447,7 +447,7 @@ static void evtchn_bind_interdom_next_vcpu(int evtchn) ...@@ -447,7 +447,7 @@ static void evtchn_bind_interdom_next_vcpu(int evtchn)
this_cpu_write(bind_last_selected_cpu, selected_cpu); this_cpu_write(bind_last_selected_cpu, selected_cpu);
/* unmask expects irqs to be disabled */ /* unmask expects irqs to be disabled */
xen_rebind_evtchn_to_cpu(evtchn, selected_cpu); xen_set_affinity_evtchn(desc, selected_cpu);
raw_spin_unlock_irqrestore(&desc->lock, flags); raw_spin_unlock_irqrestore(&desc->lock, flags);
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#define _XEN_EVENTS_H #define _XEN_EVENTS_H
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/irq.h>
#ifdef CONFIG_PCI_MSI #ifdef CONFIG_PCI_MSI
#include <linux/msi.h> #include <linux/msi.h>
#endif #endif
...@@ -59,7 +60,7 @@ void evtchn_put(unsigned int evtchn); ...@@ -59,7 +60,7 @@ void evtchn_put(unsigned int evtchn);
void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector); void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector);
void rebind_evtchn_irq(int evtchn, int irq); void rebind_evtchn_irq(int evtchn, int irq);
int xen_rebind_evtchn_to_cpu(int evtchn, unsigned tcpu); int xen_set_affinity_evtchn(struct irq_desc *desc, unsigned int tcpu);
static inline void notify_remote_via_evtchn(int port) static inline void notify_remote_via_evtchn(int port)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment