2 * linux/arch/x86_64/kernel/irq.c
4 * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
6 * This file contains the lowest level x86_64-specific interrupt
7 * entry and irq statistics code. All the remaining irq logic is
8 * done by the generic kernel/irq/ code and in the
9 * x86_64-specific irq controller code. (e.g. i8259.c and
13 #include <linux/kernel_stat.h>
14 #include <linux/interrupt.h>
15 #include <linux/seq_file.h>
16 #include <linux/module.h>
17 #include <linux/delay.h>
18 #include <linux/vs_context.h>
19 #include <asm/uaccess.h>
20 #include <asm/io_apic.h>
23 atomic_t irq_err_count;
24 #ifdef CONFIG_X86_IO_APIC
25 #ifdef APIC_MISMATCH_DEBUG
26 atomic_t irq_mis_count;
30 #ifdef CONFIG_DEBUG_STACKOVERFLOW
32 * Probabilistic stack overflow check:
34 * Only check the stack in process context, because everything else
35 * runs on the big interrupt stacks. Checking reliably is too expensive,
36 * so we just check from interrupts.
38 static inline void stack_overflow_check(struct pt_regs *regs)
40 u64 curbase = (u64) current->thread_info;
41 static unsigned long warned = -60*HZ;
43 if (regs->rsp >= curbase && regs->rsp <= curbase + THREAD_SIZE &&
44 regs->rsp < curbase + sizeof(struct thread_info) + 128 &&
45 time_after(jiffies, warned + 60*HZ)) {
46 printk("do_IRQ: %s near stack overflow (cur:%Lx,rsp:%lx)\n",
47 current->comm, curbase, regs->rsp);
48 show_stack(NULL,NULL);
55 * Generic, controller-independent functions:
58 int show_interrupts(struct seq_file *p, void *v)
60 int i = *(loff_t *) v, j;
61 struct irqaction * action;
66 for_each_online_cpu(j)
67 seq_printf(p, "CPU%-8d ",j);
72 spin_lock_irqsave(&irq_desc[i].lock, flags);
73 action = irq_desc[i].action;
76 seq_printf(p, "%3d: ",i);
78 seq_printf(p, "%10u ", kstat_irqs(i));
80 for_each_online_cpu(j)
81 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
83 seq_printf(p, " %14s", irq_desc[i].chip->typename);
85 seq_printf(p, " %s", action->name);
86 for (action=action->next; action; action = action->next)
87 seq_printf(p, ", %s", action->name);
90 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
91 } else if (i == NR_IRQS) {
92 seq_printf(p, "NMI: ");
93 for_each_online_cpu(j)
94 seq_printf(p, "%10u ", cpu_pda(j)->__nmi_count);
96 #ifdef CONFIG_X86_LOCAL_APIC
97 seq_printf(p, "LOC: ");
98 for_each_online_cpu(j)
99 seq_printf(p, "%10u ", cpu_pda(j)->apic_timer_irqs);
102 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
103 #ifdef CONFIG_X86_IO_APIC
104 #ifdef APIC_MISMATCH_DEBUG
105 seq_printf(p, "MIS: %10u\n", atomic_read(&irq_mis_count));
113 * do_IRQ handles all normal device IRQ's (the special
114 * SMP cross-CPU interrupts have their own specific
117 asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
119 /* high bit used in ret_from_ code */
120 unsigned irq = ~regs->orig_rax;
121 struct vx_info_save vxis;
123 if (unlikely(irq >= NR_IRQS)) {
124 printk(KERN_EMERG "%s: cannot handle IRQ %d\n",
132 #ifdef CONFIG_DEBUG_STACKOVERFLOW
133 stack_overflow_check(regs);
135 __enter_vx_admin(&vxis);
137 __leave_vx_admin(&vxis);
143 #ifdef CONFIG_HOTPLUG_CPU
144 void fixup_irqs(cpumask_t map)
149 for (irq = 0; irq < NR_IRQS; irq++) {
154 cpus_and(mask, irq_desc[irq].affinity, map);
155 if (any_online_cpu(mask) == NR_CPUS) {
156 printk("Breaking affinity for irq %i\n", irq);
159 if (irq_desc[irq].chip->set_affinity)
160 irq_desc[irq].chip->set_affinity(irq, mask);
161 else if (irq_desc[irq].action && !(warned++))
162 printk("Cannot set affinity for irq %i\n", irq);
165 /* That doesn't seem sufficient. Give it 1ms. */
172 extern void call_softirq(void);
174 asmlinkage void do_softirq(void)
182 local_irq_save(flags);
183 pending = local_softirq_pending();
184 /* Switch to interrupt stack */
187 WARN_ON_ONCE(softirq_count());
189 local_irq_restore(flags);
191 EXPORT_SYMBOL(do_softirq);
193 #ifndef CONFIG_X86_LOCAL_APIC
195 * 'what should we do if we get a hw irq event on an illegal vector'.
196 * each architecture has to answer this themselves.
198 void ack_bad_irq(unsigned int irq)
200 printk("unexpected IRQ trap at vector %02x\n", irq);