aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen
diff options
context:
space:
mode:
authorBoris Ostrovsky <boris.ostrovsky@oracle.com>2015-04-29 17:10:12 -0400
committerDavid Vrabel <david.vrabel@citrix.com>2015-05-05 13:27:11 -0400
commit5cec98834989a014a9560b1841649eaca95cf00e (patch)
treeb367d69594fd418d1657156fa0d4f8796207e534 /drivers/xen
parent8014bcc86ef112eab9ee1db312dba4e6b608cf89 (diff)
xen/events: Clear cpu_evtchn_mask before resuming
When a guest is resumed, the hypervisor may change event channel assignments. If this happens and the guest uses 2-level events it is possible for the interrupt to be claimed by wrong VCPU since cpu_evtchn_mask bits may be stale. This can happen even though evtchn_2l_bind_to_cpu() attempts to clear old bits: irq_info that is passed in is not necessarily the original one (from pre-migration times) but instead is freshly allocated during resume and so any information about which CPU the channel was bound to is lost. Thus we should clear the mask during resume. We also need to make sure that bits for xenstore and console channels are set when these two subsystems are resumed. While rebind_evtchn_irq() (which is invoked for both of them on a resume) calls irq_set_affinity(), the latter will in fact postpone setting affinity until handling the interrupt. But because cpu_evtchn_mask will have bits for these two cleared we won't be able to take the interrupt. With that in mind, we need to bind those two channels explicitly in rebind_evtchn_irq(). We will keep irq_set_affinity() so that we have a pass through generic irq affinity code later, in case something needs to be updated there as well. (Also replace cpumask_of(0) with cpumask_of(info->cpu) in rebind_evtchn_irq(): it should be set to zero in preceding xen_irq_info_evtchn_setup().) Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Reported-by: Annie Li <annie.li@oracle.com> Cc: <stable@vger.kernel.org> # 3.14+ Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r--drivers/xen/events/events_2l.c10
-rw-r--r--drivers/xen/events/events_base.c5
2 files changed, 13 insertions, 2 deletions
diff --git a/drivers/xen/events/events_2l.c b/drivers/xen/events/events_2l.c
index 5db43fc100a4..7dd46312c180 100644
--- a/drivers/xen/events/events_2l.c
+++ b/drivers/xen/events/events_2l.c
@@ -345,6 +345,15 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)
345 return IRQ_HANDLED; 345 return IRQ_HANDLED;
346} 346}
347 347
348static void evtchn_2l_resume(void)
349{
350 int i;
351
352 for_each_online_cpu(i)
353 memset(per_cpu(cpu_evtchn_mask, i), 0, sizeof(xen_ulong_t) *
354 EVTCHN_2L_NR_CHANNELS/BITS_PER_EVTCHN_WORD);
355}
356
348static const struct evtchn_ops evtchn_ops_2l = { 357static const struct evtchn_ops evtchn_ops_2l = {
349 .max_channels = evtchn_2l_max_channels, 358 .max_channels = evtchn_2l_max_channels,
350 .nr_channels = evtchn_2l_max_channels, 359 .nr_channels = evtchn_2l_max_channels,
@@ -356,6 +365,7 @@ static const struct evtchn_ops evtchn_ops_2l = {
356 .mask = evtchn_2l_mask, 365 .mask = evtchn_2l_mask,
357 .unmask = evtchn_2l_unmask, 366 .unmask = evtchn_2l_unmask,
358 .handle_events = evtchn_2l_handle_events, 367 .handle_events = evtchn_2l_handle_events,
368 .resume = evtchn_2l_resume,
359}; 369};
360 370
361void __init xen_evtchn_2l_init(void) 371void __init xen_evtchn_2l_init(void)
diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 70fba973a107..a1ec564d791c 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -1279,8 +1279,9 @@ void rebind_evtchn_irq(int evtchn, int irq)
1279 1279
1280 mutex_unlock(&irq_mapping_update_lock); 1280 mutex_unlock(&irq_mapping_update_lock);
1281 1281
1282 /* new event channels are always bound to cpu 0 */ 1282 bind_evtchn_to_cpu(evtchn, info->cpu);
1283 irq_set_affinity(irq, cpumask_of(0)); 1283 /* This will be deferred until interrupt is processed */
1284 irq_set_affinity(irq, cpumask_of(info->cpu));
1284 1285
1285 /* Unmask the event channel. */ 1286 /* Unmask the event channel. */
1286 enable_irq(irq); 1287 enable_irq(irq);