2
0

062-01-MIPS-Introduce-irq_stack.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. From: Matt Redfearn <matt.redfearn@imgtec.com>
  2. Date: Mon, 19 Dec 2016 14:20:56 +0000
  3. Subject: [PATCH] MIPS: Introduce irq_stack
  4. Allocate a per-cpu irq stack for use within interrupt handlers.
  5. Also add a utility function on_irq_stack to determine if a given stack
  6. pointer is within the irq stack for that cpu.
  7. Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
  8. ---
  9. --- a/arch/mips/include/asm/irq.h
  10. +++ b/arch/mips/include/asm/irq.h
  11. @@ -17,6 +17,18 @@
  12. #include <irq.h>
  13. +#define IRQ_STACK_SIZE THREAD_SIZE
  14. +
  15. +extern void *irq_stack[NR_CPUS];
  16. +
  17. +static inline bool on_irq_stack(int cpu, unsigned long sp)
  18. +{
  19. + unsigned long low = (unsigned long)irq_stack[cpu];
  20. + unsigned long high = low + IRQ_STACK_SIZE;
  21. +
  22. + return (low <= sp && sp <= high);
  23. +}
  24. +
  25. #ifdef CONFIG_I8259
  26. static inline int irq_canonicalize(int irq)
  27. {
  28. --- a/arch/mips/kernel/asm-offsets.c
  29. +++ b/arch/mips/kernel/asm-offsets.c
  30. @@ -101,6 +101,7 @@ void output_thread_info_defines(void)
  31. OFFSET(TI_REGS, thread_info, regs);
  32. DEFINE(_THREAD_SIZE, THREAD_SIZE);
  33. DEFINE(_THREAD_MASK, THREAD_MASK);
  34. + DEFINE(_IRQ_STACK_SIZE, IRQ_STACK_SIZE);
  35. BLANK();
  36. }
  37. --- a/arch/mips/kernel/irq.c
  38. +++ b/arch/mips/kernel/irq.c
  39. @@ -25,6 +25,8 @@
  40. #include <linux/atomic.h>
  41. #include <asm/uaccess.h>
  42. +void *irq_stack[NR_CPUS];
  43. +
  44. /*
  45. * 'what should we do if we get a hw irq event on an illegal vector'.
  46. * each architecture has to answer this themselves.
  47. @@ -55,6 +57,15 @@ void __init init_IRQ(void)
  48. irq_set_noprobe(i);
  49. arch_init_irq();
  50. +
  51. + for_each_possible_cpu(i) {
  52. + int irq_pages = IRQ_STACK_SIZE / PAGE_SIZE;
  53. + void *s = (void *)__get_free_pages(GFP_KERNEL, irq_pages);
  54. +
  55. + irq_stack[i] = s;
  56. + pr_debug("CPU%d IRQ stack at 0x%p - 0x%p\n", i,
  57. + irq_stack[i], irq_stack[i] + IRQ_STACK_SIZE);
  58. + }
  59. }
  60. #ifdef CONFIG_DEBUG_STACKOVERFLOW