irq_64.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
  3. *
  4. * This file contains the lowest level x86_64-specific interrupt
  5. * entry and irq statistics code. All the remaining irq logic is
  6. * done by the generic kernel/irq/ code and in the
  7. * x86_64-specific irq controller code. (e.g. i8259.c and
  8. * io_apic.c.)
  9. */
  10. #include <linux/kernel_stat.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/seq_file.h>
  13. #include <linux/module.h>
  14. #include <linux/delay.h>
  15. #include <linux/ftrace.h>
  16. #include <linux/uaccess.h>
  17. #include <linux/smp.h>
  18. #include <asm/io_apic.h>
  19. #include <asm/idle.h>
  20. #include <asm/apic.h>
  21. DEFINE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat);
  22. EXPORT_PER_CPU_SYMBOL(irq_stat);
  23. DEFINE_PER_CPU(struct pt_regs *, irq_regs);
  24. EXPORT_PER_CPU_SYMBOL(irq_regs);
  25. /*
  26. * Probabilistic stack overflow check:
  27. *
  28. * Only check the stack in process context, because everything else
  29. * runs on the big interrupt stacks. Checking reliably is too expensive,
  30. * so we just check from interrupts.
  31. */
  32. static inline void stack_overflow_check(struct pt_regs *regs)
  33. {
  34. #ifdef CONFIG_DEBUG_STACKOVERFLOW
  35. u64 curbase = (u64)task_stack_page(current);
  36. if (user_mode_vm(regs))
  37. return;
  38. WARN_ONCE(regs->sp >= curbase &&
  39. regs->sp <= curbase + THREAD_SIZE &&
  40. regs->sp < curbase + sizeof(struct thread_info) +
  41. sizeof(struct pt_regs) + 128,
  42. "do_IRQ: %s near stack overflow (cur:%Lx,sp:%lx)\n",
  43. current->comm, curbase, regs->sp);
  44. #endif
  45. }
  46. bool handle_irq(unsigned irq, struct pt_regs *regs)
  47. {
  48. struct irq_desc *desc;
  49. stack_overflow_check(regs);
  50. desc = irq_to_desc(irq);
  51. if (unlikely(!desc))
  52. return false;
  53. generic_handle_irq_desc(irq, desc);
  54. return true;
  55. }
  56. extern void call_softirq(void);
  57. asmlinkage void do_softirq(void)
  58. {
  59. __u32 pending;
  60. unsigned long flags;
  61. if (in_interrupt())
  62. return;
  63. local_irq_save(flags);
  64. pending = local_softirq_pending();
  65. /* Switch to interrupt stack */
  66. if (pending) {
  67. call_softirq();
  68. WARN_ON_ONCE(softirq_count());
  69. }
  70. local_irq_restore(flags);
  71. }