blob: d659480125f07885164353c75b83a1174049b897 [file] [log] [blame]
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -07001/*
2 * Xen event channels
3 *
4 * Xen models interrupts with abstract event channels. Because each
5 * domain gets 1024 event channels, but NR_IRQ is not that large, we
6 * must dynamically map irqs<->event channels. The event channels
7 * interface with the rest of the kernel by defining a xen interrupt
8 * chip. When an event is recieved, it is mapped to an irq and sent
9 * through the normal interrupt processing path.
10 *
11 * There are four kinds of events which can be mapped to an event
12 * channel:
13 *
14 * 1. Inter-domain notifications. This includes all the virtual
15 * device events, since they're driven by front-ends in another domain
16 * (typically dom0).
17 * 2. VIRQs, typically used for timers. These are per-cpu events.
18 * 3. IPIs.
19 * 4. Hardware interrupts. Not supported at present.
20 *
21 * Jeremy Fitzhardinge <jeremy@xensource.com>, XenSource Inc, 2007
22 */
23
24#include <linux/linkage.h>
25#include <linux/interrupt.h>
26#include <linux/irq.h>
27#include <linux/module.h>
28#include <linux/string.h>
Christophe Saout28e08862009-01-11 11:46:23 -080029#include <linux/bootmem.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090030#include <linux/slab.h>
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -070031
Sheng Yang38e20b02010-05-14 12:40:51 +010032#include <asm/desc.h>
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -070033#include <asm/ptrace.h>
34#include <asm/irq.h>
Jeremy Fitzhardinge792dc4f2009-02-06 14:09:43 -080035#include <asm/idle.h>
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -070036#include <asm/sync_bitops.h>
37#include <asm/xen/hypercall.h>
Adrian Bunk8d1b8752007-07-20 00:31:44 -070038#include <asm/xen/hypervisor.h>
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -070039
Sheng Yang38e20b02010-05-14 12:40:51 +010040#include <xen/xen.h>
41#include <xen/hvm.h>
Isaku Yamahatae04d0d02008-04-02 10:53:55 -070042#include <xen/xen-ops.h>
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -070043#include <xen/events.h>
44#include <xen/interface/xen.h>
45#include <xen/interface/event_channel.h>
Sheng Yang38e20b02010-05-14 12:40:51 +010046#include <xen/interface/hvm/hvm_op.h>
47#include <xen/interface/hvm/params.h>
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -070048
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -070049/*
50 * This lock protects updates to the following mapping and reference-count
51 * arrays. The lock does not need to be acquired to read the mapping tables.
52 */
53static DEFINE_SPINLOCK(irq_mapping_update_lock);
54
55/* IRQ <-> VIRQ mapping. */
Tejun Heo204fba42009-06-24 15:13:45 +090056static DEFINE_PER_CPU(int [NR_VIRQS], virq_to_irq) = {[0 ... NR_VIRQS-1] = -1};
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -070057
Jeremy Fitzhardingef87e4ca2007-07-17 18:37:06 -070058/* IRQ <-> IPI mapping */
Tejun Heo204fba42009-06-24 15:13:45 +090059static DEFINE_PER_CPU(int [XEN_NR_IPIS], ipi_to_irq) = {[0 ... XEN_NR_IPIS-1] = -1};
Jeremy Fitzhardingef87e4ca2007-07-17 18:37:06 -070060
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -080061/* Interrupt types. */
62enum xen_irq_type {
Jeremy Fitzhardinged77bbd42009-02-06 14:09:45 -080063 IRQT_UNBOUND = 0,
Jeremy Fitzhardingef87e4ca2007-07-17 18:37:06 -070064 IRQT_PIRQ,
65 IRQT_VIRQ,
66 IRQT_IPI,
67 IRQT_EVTCHN
68};
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -070069
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -080070/*
71 * Packed IRQ information:
72 * type - enum xen_irq_type
73 * event channel - irq->event channel mapping
74 * cpu - cpu this event channel is bound to
75 * index - type-specific information:
76 * PIRQ - vector, with MSB being "needs EIO"
77 * VIRQ - virq number
78 * IPI - IPI vector
79 * EVTCHN -
80 */
81struct irq_info
82{
83 enum xen_irq_type type; /* type */
84 unsigned short evtchn; /* event channel */
85 unsigned short cpu; /* cpu bound */
86
87 union {
88 unsigned short virq;
89 enum ipi_vector ipi;
90 struct {
91 unsigned short gsi;
92 unsigned short vector;
93 } pirq;
94 } u;
95};
96
97static struct irq_info irq_info[NR_IRQS];
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -070098
99static int evtchn_to_irq[NR_EVENT_CHANNELS] = {
100 [0 ... NR_EVENT_CHANNELS-1] = -1
101};
Mike Travisc7a35892009-01-10 21:58:11 -0800102struct cpu_evtchn_s {
103 unsigned long bits[NR_EVENT_CHANNELS/BITS_PER_LONG];
104};
105static struct cpu_evtchn_s *cpu_evtchn_mask_p;
106static inline unsigned long *cpu_evtchn_mask(int cpu)
107{
108 return cpu_evtchn_mask_p[cpu].bits;
109}
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700110
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700111/* Xen will never allocate port zero for any purpose. */
112#define VALID_EVTCHN(chn) ((chn) != 0)
113
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700114static struct irq_chip xen_dynamic_chip;
115
116/* Constructor for packed IRQ information. */
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800117static struct irq_info mk_unbound_info(void)
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700118{
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800119 return (struct irq_info) { .type = IRQT_UNBOUND };
120}
121
122static struct irq_info mk_evtchn_info(unsigned short evtchn)
123{
Ian Campbell90af9512009-02-06 16:55:58 -0800124 return (struct irq_info) { .type = IRQT_EVTCHN, .evtchn = evtchn,
125 .cpu = 0 };
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800126}
127
128static struct irq_info mk_ipi_info(unsigned short evtchn, enum ipi_vector ipi)
129{
130 return (struct irq_info) { .type = IRQT_IPI, .evtchn = evtchn,
Ian Campbell90af9512009-02-06 16:55:58 -0800131 .cpu = 0, .u.ipi = ipi };
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800132}
133
134static struct irq_info mk_virq_info(unsigned short evtchn, unsigned short virq)
135{
136 return (struct irq_info) { .type = IRQT_VIRQ, .evtchn = evtchn,
Ian Campbell90af9512009-02-06 16:55:58 -0800137 .cpu = 0, .u.virq = virq };
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800138}
139
140static struct irq_info mk_pirq_info(unsigned short evtchn,
141 unsigned short gsi, unsigned short vector)
142{
143 return (struct irq_info) { .type = IRQT_PIRQ, .evtchn = evtchn,
Ian Campbell90af9512009-02-06 16:55:58 -0800144 .cpu = 0, .u.pirq = { .gsi = gsi, .vector = vector } };
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700145}
146
147/*
148 * Accessors for packed IRQ information.
149 */
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800150static struct irq_info *info_for_irq(unsigned irq)
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700151{
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800152 return &irq_info[irq];
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700153}
154
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800155static unsigned int evtchn_from_irq(unsigned irq)
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700156{
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800157 return info_for_irq(irq)->evtchn;
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700158}
159
Ian Campbelld4c04532009-02-06 19:20:31 -0800160unsigned irq_from_evtchn(unsigned int evtchn)
161{
162 return evtchn_to_irq[evtchn];
163}
164EXPORT_SYMBOL_GPL(irq_from_evtchn);
165
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800166static enum ipi_vector ipi_from_irq(unsigned irq)
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700167{
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800168 struct irq_info *info = info_for_irq(irq);
169
170 BUG_ON(info == NULL);
171 BUG_ON(info->type != IRQT_IPI);
172
173 return info->u.ipi;
174}
175
176static unsigned virq_from_irq(unsigned irq)
177{
178 struct irq_info *info = info_for_irq(irq);
179
180 BUG_ON(info == NULL);
181 BUG_ON(info->type != IRQT_VIRQ);
182
183 return info->u.virq;
184}
185
186static unsigned gsi_from_irq(unsigned irq)
187{
188 struct irq_info *info = info_for_irq(irq);
189
190 BUG_ON(info == NULL);
191 BUG_ON(info->type != IRQT_PIRQ);
192
193 return info->u.pirq.gsi;
194}
195
196static unsigned vector_from_irq(unsigned irq)
197{
198 struct irq_info *info = info_for_irq(irq);
199
200 BUG_ON(info == NULL);
201 BUG_ON(info->type != IRQT_PIRQ);
202
203 return info->u.pirq.vector;
204}
205
206static enum xen_irq_type type_from_irq(unsigned irq)
207{
208 return info_for_irq(irq)->type;
209}
210
211static unsigned cpu_from_irq(unsigned irq)
212{
213 return info_for_irq(irq)->cpu;
214}
215
216static unsigned int cpu_from_evtchn(unsigned int evtchn)
217{
218 int irq = evtchn_to_irq[evtchn];
219 unsigned ret = 0;
220
221 if (irq != -1)
222 ret = cpu_from_irq(irq);
223
224 return ret;
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700225}
226
227static inline unsigned long active_evtchns(unsigned int cpu,
228 struct shared_info *sh,
229 unsigned int idx)
230{
231 return (sh->evtchn_pending[idx] &
Mike Travisc7a35892009-01-10 21:58:11 -0800232 cpu_evtchn_mask(cpu)[idx] &
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700233 ~sh->evtchn_mask[idx]);
234}
235
236static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)
237{
238 int irq = evtchn_to_irq[chn];
239
240 BUG_ON(irq == -1);
241#ifdef CONFIG_SMP
Mike Travis7f7ace02009-01-10 21:58:08 -0800242 cpumask_copy(irq_to_desc(irq)->affinity, cpumask_of(cpu));
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700243#endif
244
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800245 __clear_bit(chn, cpu_evtchn_mask(cpu_from_irq(irq)));
Mike Travisc7a35892009-01-10 21:58:11 -0800246 __set_bit(chn, cpu_evtchn_mask(cpu));
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700247
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800248 irq_info[irq].cpu = cpu;
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700249}
250
251static void init_evtchn_cpu_bindings(void)
252{
253#ifdef CONFIG_SMP
Thomas Gleixner10e58082008-10-16 14:19:04 +0200254 struct irq_desc *desc;
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700255 int i;
Thomas Gleixner10e58082008-10-16 14:19:04 +0200256
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700257 /* By default all event channels notify CPU#0. */
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800258 for_each_irq_desc(i, desc) {
Mike Travis7f7ace02009-01-10 21:58:08 -0800259 cpumask_copy(desc->affinity, cpumask_of(0));
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800260 }
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700261#endif
262
Mike Travisc7a35892009-01-10 21:58:11 -0800263 memset(cpu_evtchn_mask(0), ~0, sizeof(cpu_evtchn_mask(0)));
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700264}
265
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700266static inline void clear_evtchn(int port)
267{
268 struct shared_info *s = HYPERVISOR_shared_info;
269 sync_clear_bit(port, &s->evtchn_pending[0]);
270}
271
272static inline void set_evtchn(int port)
273{
274 struct shared_info *s = HYPERVISOR_shared_info;
275 sync_set_bit(port, &s->evtchn_pending[0]);
276}
277
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700278static inline int test_evtchn(int port)
279{
280 struct shared_info *s = HYPERVISOR_shared_info;
281 return sync_test_bit(port, &s->evtchn_pending[0]);
282}
283
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700284
285/**
286 * notify_remote_via_irq - send event to remote end of event channel via irq
287 * @irq: irq of event channel to send event to
288 *
289 * Unlike notify_remote_via_evtchn(), this is safe to use across
290 * save/restore. Notifications on a broken connection are silently
291 * dropped.
292 */
293void notify_remote_via_irq(int irq)
294{
295 int evtchn = evtchn_from_irq(irq);
296
297 if (VALID_EVTCHN(evtchn))
298 notify_remote_via_evtchn(evtchn);
299}
300EXPORT_SYMBOL_GPL(notify_remote_via_irq);
301
302static void mask_evtchn(int port)
303{
304 struct shared_info *s = HYPERVISOR_shared_info;
305 sync_set_bit(port, &s->evtchn_mask[0]);
306}
307
308static void unmask_evtchn(int port)
309{
310 struct shared_info *s = HYPERVISOR_shared_info;
311 unsigned int cpu = get_cpu();
312
313 BUG_ON(!irqs_disabled());
314
315 /* Slow path (hypercall) if this is a non-local port. */
316 if (unlikely(cpu != cpu_from_evtchn(port))) {
317 struct evtchn_unmask unmask = { .port = port };
318 (void)HYPERVISOR_event_channel_op(EVTCHNOP_unmask, &unmask);
319 } else {
320 struct vcpu_info *vcpu_info = __get_cpu_var(xen_vcpu);
321
322 sync_clear_bit(port, &s->evtchn_mask[0]);
323
324 /*
325 * The following is basically the equivalent of
326 * 'hw_resend_irq'. Just like a real IO-APIC we 'lose
327 * the interrupt edge' if the channel is masked.
328 */
329 if (sync_test_bit(port, &s->evtchn_pending[0]) &&
330 !sync_test_and_set_bit(port / BITS_PER_LONG,
331 &vcpu_info->evtchn_pending_sel))
332 vcpu_info->evtchn_upcall_pending = 1;
333 }
334
335 put_cpu();
336}
337
338static int find_unbound_irq(void)
339{
340 int irq;
Jeremy Fitzhardinge6f8a0ed2008-12-17 13:42:29 -0800341 struct irq_desc *desc;
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700342
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800343 for (irq = 0; irq < nr_irqs; irq++)
Jeremy Fitzhardinged77bbd42009-02-06 14:09:45 -0800344 if (irq_info[irq].type == IRQT_UNBOUND)
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700345 break;
346
Yinghai Lu5a15d7e2008-08-19 20:49:57 -0700347 if (irq == nr_irqs)
348 panic("No available IRQ to bind to: increase nr_irqs!\n");
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700349
Yinghai Lu85ac16d2009-04-27 18:00:38 -0700350 desc = irq_to_desc_alloc_node(irq, 0);
Jeremy Fitzhardinge6f8a0ed2008-12-17 13:42:29 -0800351 if (WARN_ON(desc == NULL))
352 return -1;
353
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800354 dynamic_irq_init(irq);
355
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700356 return irq;
357}
358
Jeremy Fitzhardingeb536b4b2007-07-17 18:37:06 -0700359int bind_evtchn_to_irq(unsigned int evtchn)
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700360{
361 int irq;
362
363 spin_lock(&irq_mapping_update_lock);
364
365 irq = evtchn_to_irq[evtchn];
366
367 if (irq == -1) {
368 irq = find_unbound_irq();
369
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700370 set_irq_chip_and_handler_name(irq, &xen_dynamic_chip,
371 handle_level_irq, "event");
372
373 evtchn_to_irq[evtchn] = irq;
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800374 irq_info[irq] = mk_evtchn_info(evtchn);
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700375 }
376
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700377 spin_unlock(&irq_mapping_update_lock);
378
379 return irq;
380}
Jeremy Fitzhardingeb536b4b2007-07-17 18:37:06 -0700381EXPORT_SYMBOL_GPL(bind_evtchn_to_irq);
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700382
Jeremy Fitzhardingef87e4ca2007-07-17 18:37:06 -0700383static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)
384{
385 struct evtchn_bind_ipi bind_ipi;
386 int evtchn, irq;
387
388 spin_lock(&irq_mapping_update_lock);
389
390 irq = per_cpu(ipi_to_irq, cpu)[ipi];
Ian Campbell90af9512009-02-06 16:55:58 -0800391
Jeremy Fitzhardingef87e4ca2007-07-17 18:37:06 -0700392 if (irq == -1) {
393 irq = find_unbound_irq();
394 if (irq < 0)
395 goto out;
396
Jeremy Fitzhardingef87e4ca2007-07-17 18:37:06 -0700397 set_irq_chip_and_handler_name(irq, &xen_dynamic_chip,
398 handle_level_irq, "ipi");
399
400 bind_ipi.vcpu = cpu;
401 if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi,
402 &bind_ipi) != 0)
403 BUG();
404 evtchn = bind_ipi.port;
405
406 evtchn_to_irq[evtchn] = irq;
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800407 irq_info[irq] = mk_ipi_info(evtchn, ipi);
Jeremy Fitzhardingef87e4ca2007-07-17 18:37:06 -0700408 per_cpu(ipi_to_irq, cpu)[ipi] = irq;
409
410 bind_evtchn_to_cpu(evtchn, cpu);
411 }
412
Jeremy Fitzhardingef87e4ca2007-07-17 18:37:06 -0700413 out:
414 spin_unlock(&irq_mapping_update_lock);
415 return irq;
416}
417
418
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700419static int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
420{
421 struct evtchn_bind_virq bind_virq;
422 int evtchn, irq;
423
424 spin_lock(&irq_mapping_update_lock);
425
426 irq = per_cpu(virq_to_irq, cpu)[virq];
427
428 if (irq == -1) {
429 bind_virq.virq = virq;
430 bind_virq.vcpu = cpu;
431 if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq,
432 &bind_virq) != 0)
433 BUG();
434 evtchn = bind_virq.port;
435
436 irq = find_unbound_irq();
437
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700438 set_irq_chip_and_handler_name(irq, &xen_dynamic_chip,
439 handle_level_irq, "virq");
440
441 evtchn_to_irq[evtchn] = irq;
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800442 irq_info[irq] = mk_virq_info(evtchn, virq);
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700443
444 per_cpu(virq_to_irq, cpu)[virq] = irq;
445
446 bind_evtchn_to_cpu(evtchn, cpu);
447 }
448
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700449 spin_unlock(&irq_mapping_update_lock);
450
451 return irq;
452}
453
454static void unbind_from_irq(unsigned int irq)
455{
456 struct evtchn_close close;
457 int evtchn = evtchn_from_irq(irq);
458
459 spin_lock(&irq_mapping_update_lock);
460
Jeremy Fitzhardinged77bbd42009-02-06 14:09:45 -0800461 if (VALID_EVTCHN(evtchn)) {
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700462 close.port = evtchn;
463 if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0)
464 BUG();
465
466 switch (type_from_irq(irq)) {
467 case IRQT_VIRQ:
468 per_cpu(virq_to_irq, cpu_from_evtchn(evtchn))
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800469 [virq_from_irq(irq)] = -1;
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700470 break;
Alex Nixond68d82a2008-08-22 11:52:15 +0100471 case IRQT_IPI:
472 per_cpu(ipi_to_irq, cpu_from_evtchn(evtchn))
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800473 [ipi_from_irq(irq)] = -1;
Alex Nixond68d82a2008-08-22 11:52:15 +0100474 break;
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700475 default:
476 break;
477 }
478
479 /* Closed ports are implicitly re-bound to VCPU0. */
480 bind_evtchn_to_cpu(evtchn, 0);
481
482 evtchn_to_irq[evtchn] = -1;
Ian Campbellfed5ea82009-12-01 16:15:30 +0000483 }
484
485 if (irq_info[irq].type != IRQT_UNBOUND) {
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800486 irq_info[irq] = mk_unbound_info();
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700487
Jeremy Fitzhardinge0f2287a2008-05-26 23:31:24 +0100488 dynamic_irq_cleanup(irq);
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700489 }
490
491 spin_unlock(&irq_mapping_update_lock);
492}
493
494int bind_evtchn_to_irqhandler(unsigned int evtchn,
Jeff Garzik7c239972007-10-19 03:12:20 -0400495 irq_handler_t handler,
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700496 unsigned long irqflags,
497 const char *devname, void *dev_id)
498{
499 unsigned int irq;
500 int retval;
501
502 irq = bind_evtchn_to_irq(evtchn);
503 retval = request_irq(irq, handler, irqflags, devname, dev_id);
504 if (retval != 0) {
505 unbind_from_irq(irq);
506 return retval;
507 }
508
509 return irq;
510}
511EXPORT_SYMBOL_GPL(bind_evtchn_to_irqhandler);
512
513int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu,
Jeff Garzik7c239972007-10-19 03:12:20 -0400514 irq_handler_t handler,
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700515 unsigned long irqflags, const char *devname, void *dev_id)
516{
517 unsigned int irq;
518 int retval;
519
520 irq = bind_virq_to_irq(virq, cpu);
521 retval = request_irq(irq, handler, irqflags, devname, dev_id);
522 if (retval != 0) {
523 unbind_from_irq(irq);
524 return retval;
525 }
526
527 return irq;
528}
529EXPORT_SYMBOL_GPL(bind_virq_to_irqhandler);
530
Jeremy Fitzhardingef87e4ca2007-07-17 18:37:06 -0700531int bind_ipi_to_irqhandler(enum ipi_vector ipi,
532 unsigned int cpu,
533 irq_handler_t handler,
534 unsigned long irqflags,
535 const char *devname,
536 void *dev_id)
537{
538 int irq, retval;
539
540 irq = bind_ipi_to_irq(ipi, cpu);
541 if (irq < 0)
542 return irq;
543
544 retval = request_irq(irq, handler, irqflags, devname, dev_id);
545 if (retval != 0) {
546 unbind_from_irq(irq);
547 return retval;
548 }
549
550 return irq;
551}
552
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700553void unbind_from_irqhandler(unsigned int irq, void *dev_id)
554{
555 free_irq(irq, dev_id);
556 unbind_from_irq(irq);
557}
558EXPORT_SYMBOL_GPL(unbind_from_irqhandler);
559
Jeremy Fitzhardingef87e4ca2007-07-17 18:37:06 -0700560void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector)
561{
562 int irq = per_cpu(ipi_to_irq, cpu)[vector];
563 BUG_ON(irq < 0);
564 notify_remote_via_irq(irq);
565}
566
Jeremy Fitzhardingeee523ca2008-03-17 16:37:18 -0700567irqreturn_t xen_debug_interrupt(int irq, void *dev_id)
568{
569 struct shared_info *sh = HYPERVISOR_shared_info;
570 int cpu = smp_processor_id();
571 int i;
572 unsigned long flags;
573 static DEFINE_SPINLOCK(debug_lock);
574
575 spin_lock_irqsave(&debug_lock, flags);
576
577 printk("vcpu %d\n ", cpu);
578
579 for_each_online_cpu(i) {
580 struct vcpu_info *v = per_cpu(xen_vcpu, i);
581 printk("%d: masked=%d pending=%d event_sel %08lx\n ", i,
Isaku Yamahatae849c3e2008-04-02 10:53:56 -0700582 (get_irq_regs() && i == cpu) ? xen_irqs_disabled(get_irq_regs()) : v->evtchn_upcall_mask,
Jeremy Fitzhardingeee523ca2008-03-17 16:37:18 -0700583 v->evtchn_upcall_pending,
584 v->evtchn_pending_sel);
585 }
586 printk("pending:\n ");
587 for(i = ARRAY_SIZE(sh->evtchn_pending)-1; i >= 0; i--)
588 printk("%08lx%s", sh->evtchn_pending[i],
589 i % 8 == 0 ? "\n " : " ");
590 printk("\nmasks:\n ");
591 for(i = ARRAY_SIZE(sh->evtchn_mask)-1; i >= 0; i--)
592 printk("%08lx%s", sh->evtchn_mask[i],
593 i % 8 == 0 ? "\n " : " ");
594
595 printk("\nunmasked:\n ");
596 for(i = ARRAY_SIZE(sh->evtchn_mask)-1; i >= 0; i--)
597 printk("%08lx%s", sh->evtchn_pending[i] & ~sh->evtchn_mask[i],
598 i % 8 == 0 ? "\n " : " ");
599
600 printk("\npending list:\n");
601 for(i = 0; i < NR_EVENT_CHANNELS; i++) {
602 if (sync_test_bit(i, sh->evtchn_pending)) {
603 printk(" %d: event %d -> irq %d\n",
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800604 cpu_from_evtchn(i), i,
605 evtchn_to_irq[i]);
Jeremy Fitzhardingeee523ca2008-03-17 16:37:18 -0700606 }
607 }
608
609 spin_unlock_irqrestore(&debug_lock, flags);
610
611 return IRQ_HANDLED;
612}
613
Tejun Heo245b2e72009-06-24 15:13:48 +0900614static DEFINE_PER_CPU(unsigned, xed_nesting_count);
615
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700616/*
617 * Search the CPUs pending events bitmasks. For each one found, map
618 * the event number to an irq, and feed it into do_IRQ() for
619 * handling.
620 *
621 * Xen uses a two-level bitmap to speed searching. The first level is
622 * a bitset of words which contain pending event bits. The second
623 * level is a bitset of pending events themselves.
624 */
Sheng Yang38e20b02010-05-14 12:40:51 +0100625static void __xen_evtchn_do_upcall(void)
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700626{
627 int cpu = get_cpu();
628 struct shared_info *s = HYPERVISOR_shared_info;
629 struct vcpu_info *vcpu_info = __get_cpu_var(xen_vcpu);
Jeremy Fitzhardinge229664b2008-03-17 16:37:20 -0700630 unsigned count;
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700631
Jeremy Fitzhardinge229664b2008-03-17 16:37:20 -0700632 do {
633 unsigned long pending_words;
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700634
Jeremy Fitzhardinge229664b2008-03-17 16:37:20 -0700635 vcpu_info->evtchn_upcall_pending = 0;
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700636
Tejun Heo245b2e72009-06-24 15:13:48 +0900637 if (__get_cpu_var(xed_nesting_count)++)
Jeremy Fitzhardinge229664b2008-03-17 16:37:20 -0700638 goto out;
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700639
Isaku Yamahatae849c3e2008-04-02 10:53:56 -0700640#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */
641 /* Clear master flag /before/ clearing selector flag. */
Isaku Yamahata6673cf62008-06-16 14:58:13 -0700642 wmb();
Isaku Yamahatae849c3e2008-04-02 10:53:56 -0700643#endif
Jeremy Fitzhardinge229664b2008-03-17 16:37:20 -0700644 pending_words = xchg(&vcpu_info->evtchn_pending_sel, 0);
645 while (pending_words != 0) {
646 unsigned long pending_bits;
647 int word_idx = __ffs(pending_words);
648 pending_words &= ~(1UL << word_idx);
649
650 while ((pending_bits = active_evtchns(cpu, s, word_idx)) != 0) {
651 int bit_idx = __ffs(pending_bits);
652 int port = (word_idx * BITS_PER_LONG) + bit_idx;
653 int irq = evtchn_to_irq[port];
Eric W. Biedermanca4dbc62010-02-17 18:49:54 -0800654 struct irq_desc *desc;
Jeremy Fitzhardinge229664b2008-03-17 16:37:20 -0700655
Eric W. Biedermanca4dbc62010-02-17 18:49:54 -0800656 if (irq != -1) {
657 desc = irq_to_desc(irq);
658 if (desc)
659 generic_handle_irq_desc(irq, desc);
660 }
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700661 }
662 }
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700663
Jeremy Fitzhardinge229664b2008-03-17 16:37:20 -0700664 BUG_ON(!irqs_disabled());
665
Tejun Heo245b2e72009-06-24 15:13:48 +0900666 count = __get_cpu_var(xed_nesting_count);
667 __get_cpu_var(xed_nesting_count) = 0;
Jeremy Fitzhardinge229664b2008-03-17 16:37:20 -0700668 } while(count != 1);
669
670out:
Jeremy Fitzhardinge3445a8f2009-02-06 14:09:46 -0800671
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700672 put_cpu();
673}
674
Sheng Yang38e20b02010-05-14 12:40:51 +0100675void xen_evtchn_do_upcall(struct pt_regs *regs)
676{
677 struct pt_regs *old_regs = set_irq_regs(regs);
678
679 exit_idle();
680 irq_enter();
681
682 __xen_evtchn_do_upcall();
683
684 irq_exit();
685 set_irq_regs(old_regs);
686}
687
688void xen_hvm_evtchn_do_upcall(void)
689{
690 __xen_evtchn_do_upcall();
691}
692
Jeremy Fitzhardingeeb1e3052008-05-26 23:31:23 +0100693/* Rebind a new event channel to an existing irq. */
694void rebind_evtchn_irq(int evtchn, int irq)
695{
Jeremy Fitzhardinged77bbd42009-02-06 14:09:45 -0800696 struct irq_info *info = info_for_irq(irq);
697
Jeremy Fitzhardingeeb1e3052008-05-26 23:31:23 +0100698 /* Make sure the irq is masked, since the new event channel
699 will also be masked. */
700 disable_irq(irq);
701
702 spin_lock(&irq_mapping_update_lock);
703
704 /* After resume the irq<->evtchn mappings are all cleared out */
705 BUG_ON(evtchn_to_irq[evtchn] != -1);
706 /* Expect irq to have been bound before,
Jeremy Fitzhardinged77bbd42009-02-06 14:09:45 -0800707 so there should be a proper type */
708 BUG_ON(info->type == IRQT_UNBOUND);
Jeremy Fitzhardingeeb1e3052008-05-26 23:31:23 +0100709
710 evtchn_to_irq[evtchn] = irq;
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800711 irq_info[irq] = mk_evtchn_info(evtchn);
Jeremy Fitzhardingeeb1e3052008-05-26 23:31:23 +0100712
713 spin_unlock(&irq_mapping_update_lock);
714
715 /* new event channels are always bound to cpu 0 */
Rusty Russell0de26522008-12-13 21:20:26 +1030716 irq_set_affinity(irq, cpumask_of(0));
Jeremy Fitzhardingeeb1e3052008-05-26 23:31:23 +0100717
718 /* Unmask the event channel. */
719 enable_irq(irq);
720}
721
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700722/* Rebind an evtchn so that it gets delivered to a specific cpu */
Yinghai Lud5dedd42009-04-27 17:59:21 -0700723static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700724{
725 struct evtchn_bind_vcpu bind_vcpu;
726 int evtchn = evtchn_from_irq(irq);
727
728 if (!VALID_EVTCHN(evtchn))
Yinghai Lud5dedd42009-04-27 17:59:21 -0700729 return -1;
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700730
731 /* Send future instances of this interrupt to other vcpu. */
732 bind_vcpu.port = evtchn;
733 bind_vcpu.vcpu = tcpu;
734
735 /*
736 * If this fails, it usually just indicates that we're dealing with a
737 * virq or IPI channel, which don't actually need to be rebound. Ignore
738 * it, but don't do the xenlinux-level rebind in that case.
739 */
740 if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0)
741 bind_evtchn_to_cpu(evtchn, tcpu);
Yinghai Lud5dedd42009-04-27 17:59:21 -0700742
743 return 0;
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700744}
745
Yinghai Lud5dedd42009-04-27 17:59:21 -0700746static int set_affinity_irq(unsigned irq, const struct cpumask *dest)
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700747{
Rusty Russell0de26522008-12-13 21:20:26 +1030748 unsigned tcpu = cpumask_first(dest);
Yinghai Lud5dedd42009-04-27 17:59:21 -0700749
750 return rebind_irq_to_cpu(irq, tcpu);
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700751}
752
Isaku Yamahata642e0c82008-04-02 10:53:57 -0700753int resend_irq_on_evtchn(unsigned int irq)
754{
755 int masked, evtchn = evtchn_from_irq(irq);
756 struct shared_info *s = HYPERVISOR_shared_info;
757
758 if (!VALID_EVTCHN(evtchn))
759 return 1;
760
761 masked = sync_test_and_set_bit(evtchn, s->evtchn_mask);
762 sync_set_bit(evtchn, s->evtchn_pending);
763 if (!masked)
764 unmask_evtchn(evtchn);
765
766 return 1;
767}
768
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700769static void enable_dynirq(unsigned int irq)
770{
771 int evtchn = evtchn_from_irq(irq);
772
773 if (VALID_EVTCHN(evtchn))
774 unmask_evtchn(evtchn);
775}
776
777static void disable_dynirq(unsigned int irq)
778{
779 int evtchn = evtchn_from_irq(irq);
780
781 if (VALID_EVTCHN(evtchn))
782 mask_evtchn(evtchn);
783}
784
785static void ack_dynirq(unsigned int irq)
786{
787 int evtchn = evtchn_from_irq(irq);
788
789 move_native_irq(irq);
790
791 if (VALID_EVTCHN(evtchn))
792 clear_evtchn(evtchn);
793}
794
795static int retrigger_dynirq(unsigned int irq)
796{
797 int evtchn = evtchn_from_irq(irq);
Jeremy Fitzhardingeee8fa1c2008-03-17 16:37:19 -0700798 struct shared_info *sh = HYPERVISOR_shared_info;
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700799 int ret = 0;
800
801 if (VALID_EVTCHN(evtchn)) {
Jeremy Fitzhardingeee8fa1c2008-03-17 16:37:19 -0700802 int masked;
803
804 masked = sync_test_and_set_bit(evtchn, sh->evtchn_mask);
805 sync_set_bit(evtchn, sh->evtchn_pending);
806 if (!masked)
807 unmask_evtchn(evtchn);
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700808 ret = 1;
809 }
810
811 return ret;
812}
813
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +0100814static void restore_cpu_virqs(unsigned int cpu)
815{
816 struct evtchn_bind_virq bind_virq;
817 int virq, irq, evtchn;
818
819 for (virq = 0; virq < NR_VIRQS; virq++) {
820 if ((irq = per_cpu(virq_to_irq, cpu)[virq]) == -1)
821 continue;
822
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800823 BUG_ON(virq_from_irq(irq) != virq);
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +0100824
825 /* Get a new binding from Xen. */
826 bind_virq.virq = virq;
827 bind_virq.vcpu = cpu;
828 if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq,
829 &bind_virq) != 0)
830 BUG();
831 evtchn = bind_virq.port;
832
833 /* Record the new mapping. */
834 evtchn_to_irq[evtchn] = irq;
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800835 irq_info[irq] = mk_virq_info(evtchn, virq);
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +0100836 bind_evtchn_to_cpu(evtchn, cpu);
837
838 /* Ready for use. */
839 unmask_evtchn(evtchn);
840 }
841}
842
843static void restore_cpu_ipis(unsigned int cpu)
844{
845 struct evtchn_bind_ipi bind_ipi;
846 int ipi, irq, evtchn;
847
848 for (ipi = 0; ipi < XEN_NR_IPIS; ipi++) {
849 if ((irq = per_cpu(ipi_to_irq, cpu)[ipi]) == -1)
850 continue;
851
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800852 BUG_ON(ipi_from_irq(irq) != ipi);
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +0100853
854 /* Get a new binding from Xen. */
855 bind_ipi.vcpu = cpu;
856 if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi,
857 &bind_ipi) != 0)
858 BUG();
859 evtchn = bind_ipi.port;
860
861 /* Record the new mapping. */
862 evtchn_to_irq[evtchn] = irq;
Jeremy Fitzhardingeced40d02009-02-06 14:09:44 -0800863 irq_info[irq] = mk_ipi_info(evtchn, ipi);
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +0100864 bind_evtchn_to_cpu(evtchn, cpu);
865
866 /* Ready for use. */
867 unmask_evtchn(evtchn);
868
869 }
870}
871
Jeremy Fitzhardinge2d9e1e22008-07-07 12:07:53 -0700872/* Clear an irq's pending state, in preparation for polling on it */
873void xen_clear_irq_pending(int irq)
874{
875 int evtchn = evtchn_from_irq(irq);
876
877 if (VALID_EVTCHN(evtchn))
878 clear_evtchn(evtchn);
879}
880
Jeremy Fitzhardinge168d2f42008-08-20 17:02:18 -0700881void xen_set_irq_pending(int irq)
882{
883 int evtchn = evtchn_from_irq(irq);
884
885 if (VALID_EVTCHN(evtchn))
886 set_evtchn(evtchn);
887}
888
889bool xen_test_irq_pending(int irq)
890{
891 int evtchn = evtchn_from_irq(irq);
892 bool ret = false;
893
894 if (VALID_EVTCHN(evtchn))
895 ret = test_evtchn(evtchn);
896
897 return ret;
898}
899
Jeremy Fitzhardinge2d9e1e22008-07-07 12:07:53 -0700900/* Poll waiting for an irq to become pending. In the usual case, the
901 irq will be disabled so it won't deliver an interrupt. */
902void xen_poll_irq(int irq)
903{
904 evtchn_port_t evtchn = evtchn_from_irq(irq);
905
906 if (VALID_EVTCHN(evtchn)) {
907 struct sched_poll poll;
908
909 poll.nr_ports = 1;
910 poll.timeout = 0;
Isaku Yamahataff3c5362008-10-14 17:50:44 -0700911 set_xen_guest_handle(poll.ports, &evtchn);
Jeremy Fitzhardinge2d9e1e22008-07-07 12:07:53 -0700912
913 if (HYPERVISOR_sched_op(SCHEDOP_poll, &poll) != 0)
914 BUG();
915 }
916}
917
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +0100918void xen_irq_resume(void)
919{
920 unsigned int cpu, irq, evtchn;
921
922 init_evtchn_cpu_bindings();
923
924 /* New event-channel space is not 'live' yet. */
925 for (evtchn = 0; evtchn < NR_EVENT_CHANNELS; evtchn++)
926 mask_evtchn(evtchn);
927
928 /* No IRQ <-> event-channel mappings. */
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800929 for (irq = 0; irq < nr_irqs; irq++)
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +0100930 irq_info[irq].evtchn = 0; /* zap event-channel binding */
931
932 for (evtchn = 0; evtchn < NR_EVENT_CHANNELS; evtchn++)
933 evtchn_to_irq[evtchn] = -1;
934
935 for_each_possible_cpu(cpu) {
936 restore_cpu_virqs(cpu);
937 restore_cpu_ipis(cpu);
938 }
939}
940
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700941static struct irq_chip xen_dynamic_chip __read_mostly = {
942 .name = "xen-dyn",
Jeremy Fitzhardinge54a353a2009-02-06 14:09:42 -0800943
944 .disable = disable_dynirq,
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700945 .mask = disable_dynirq,
946 .unmask = enable_dynirq,
Jeremy Fitzhardinge54a353a2009-02-06 14:09:42 -0800947
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700948 .ack = ack_dynirq,
949 .set_affinity = set_affinity_irq,
950 .retrigger = retrigger_dynirq,
951};
952
Sheng Yang38e20b02010-05-14 12:40:51 +0100953int xen_set_callback_via(uint64_t via)
954{
955 struct xen_hvm_param a;
956 a.domid = DOMID_SELF;
957 a.index = HVM_PARAM_CALLBACK_IRQ;
958 a.value = via;
959 return HYPERVISOR_hvm_op(HVMOP_set_param, &a);
960}
961EXPORT_SYMBOL_GPL(xen_set_callback_via);
962
963/* Vector callbacks are better than PCI interrupts to receive event
964 * channel notifications because we can receive vector callbacks on any
965 * vcpu and we don't need PCI support or APIC interactions. */
966void xen_callback_vector(void)
967{
968 int rc;
969 uint64_t callback_via;
970 if (xen_have_vector_callback) {
971 callback_via = HVM_CALLBACK_VECTOR(XEN_HVM_EVTCHN_CALLBACK);
972 rc = xen_set_callback_via(callback_via);
973 if (rc) {
974 printk(KERN_ERR "Request for Xen HVM callback vector"
975 " failed.\n");
976 xen_have_vector_callback = 0;
977 return;
978 }
979 printk(KERN_INFO "Xen HVM callback vector for event delivery is "
980 "enabled\n");
981 /* in the restore case the vector has already been allocated */
982 if (!test_bit(XEN_HVM_EVTCHN_CALLBACK, used_vectors))
983 alloc_intr_gate(XEN_HVM_EVTCHN_CALLBACK, xen_hvm_callback_vector);
984 }
985}
986
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700987void __init xen_init_IRQ(void)
988{
989 int i;
Mike Travisc7a35892009-01-10 21:58:11 -0800990
Pekka Enberga70c3522009-07-01 11:51:18 +0300991 cpu_evtchn_mask_p = kcalloc(nr_cpu_ids, sizeof(struct cpu_evtchn_s),
992 GFP_KERNEL);
Christophe Saout28e08862009-01-11 11:46:23 -0800993 BUG_ON(cpu_evtchn_mask_p == NULL);
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -0700994
995 init_evtchn_cpu_bindings();
996
997 /* No event channels are 'live' right now. */
998 for (i = 0; i < NR_EVENT_CHANNELS; i++)
999 mask_evtchn(i);
1000
Sheng Yang38e20b02010-05-14 12:40:51 +01001001 if (xen_hvm_domain()) {
1002 xen_callback_vector();
1003 native_init_IRQ();
1004 } else {
1005 irq_ctx_init(smp_processor_id());
1006 }
Jeremy Fitzhardingee46cdb62007-07-17 18:37:05 -07001007}