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
5 Allocate a per-cpu irq stack for use within interrupt handlers.
7 Also add a utility function on_irq_stack to determine if a given stack
8 pointer is within the irq stack for that cpu.
10 Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
13 --- a/arch/mips/include/asm/irq.h
14 +++ b/arch/mips/include/asm/irq.h
19 +#define IRQ_STACK_SIZE THREAD_SIZE
21 +extern void *irq_stack[NR_CPUS];
23 +static inline bool on_irq_stack(int cpu, unsigned long sp)
25 + unsigned long low = (unsigned long)irq_stack[cpu];
26 + unsigned long high = low + IRQ_STACK_SIZE;
28 + return (low <= sp && sp <= high);
32 static inline int irq_canonicalize(int irq)
34 --- a/arch/mips/kernel/asm-offsets.c
35 +++ b/arch/mips/kernel/asm-offsets.c
36 @@ -102,6 +102,7 @@ void output_thread_info_defines(void)
37 OFFSET(TI_REGS, thread_info, regs);
38 DEFINE(_THREAD_SIZE, THREAD_SIZE);
39 DEFINE(_THREAD_MASK, THREAD_MASK);
40 + DEFINE(_IRQ_STACK_SIZE, IRQ_STACK_SIZE);
44 --- a/arch/mips/kernel/irq.c
45 +++ b/arch/mips/kernel/irq.c
47 #include <linux/atomic.h>
48 #include <asm/uaccess.h>
50 +void *irq_stack[NR_CPUS];
53 * 'what should we do if we get a hw irq event on an illegal vector'.
54 * each architecture has to answer this themselves.
55 @@ -58,6 +60,15 @@ void __init init_IRQ(void)
56 clear_c0_status(ST0_IM);
60 + for_each_possible_cpu(i) {
61 + int irq_pages = IRQ_STACK_SIZE / PAGE_SIZE;
62 + void *s = (void *)__get_free_pages(GFP_KERNEL, irq_pages);
65 + pr_debug("CPU%d IRQ stack at 0x%p - 0x%p\n", i,
66 + irq_stack[i], irq_stack[i] + IRQ_STACK_SIZE);
70 #ifdef CONFIG_DEBUG_STACKOVERFLOW