Skip to content

Commit fe8bd18

Browse files
mpredfearnralfbaechle
authored andcommitted
MIPS: Introduce irq_stack
Allocate a per-cpu irq stack for use within interrupt handlers. Also add a utility function on_irq_stack to determine if a given stack pointer is within the irq stack for that cpu. Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com> Acked-by: Jason A. Donenfeld <jason@zx2c4.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Chris Metcalf <cmetcalf@mellanox.com> Cc: Petr Mladek <pmladek@suse.com> Cc: James Hogan <james.hogan@imgtec.com> Cc: Paul Burton <paul.burton@imgtec.com> Cc: Aaron Tomlin <atomlin@redhat.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: linux-kernel@vger.kernel.org Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/14740/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent ae2f5e5 commit fe8bd18

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

arch/mips/include/asm/irq.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@
1717

1818
#include <irq.h>
1919

20+
#define IRQ_STACK_SIZE THREAD_SIZE
21+
22+
extern void *irq_stack[NR_CPUS];
23+
24+
static inline bool on_irq_stack(int cpu, unsigned long sp)
25+
{
26+
unsigned long low = (unsigned long)irq_stack[cpu];
27+
unsigned long high = low + IRQ_STACK_SIZE;
28+
29+
return (low <= sp && sp <= high);
30+
}
31+
2032
#ifdef CONFIG_I8259
2133
static inline int irq_canonicalize(int irq)
2234
{

arch/mips/kernel/asm-offsets.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ void output_thread_info_defines(void)
102102
OFFSET(TI_REGS, thread_info, regs);
103103
DEFINE(_THREAD_SIZE, THREAD_SIZE);
104104
DEFINE(_THREAD_MASK, THREAD_MASK);
105+
DEFINE(_IRQ_STACK_SIZE, IRQ_STACK_SIZE);
105106
BLANK();
106107
}
107108

arch/mips/kernel/irq.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <linux/atomic.h>
2626
#include <linux/uaccess.h>
2727

28+
void *irq_stack[NR_CPUS];
29+
2830
/*
2931
* 'what should we do if we get a hw irq event on an illegal vector'.
3032
* each architecture has to answer this themselves.
@@ -58,6 +60,15 @@ void __init init_IRQ(void)
5860
clear_c0_status(ST0_IM);
5961

6062
arch_init_irq();
63+
64+
for_each_possible_cpu(i) {
65+
int irq_pages = IRQ_STACK_SIZE / PAGE_SIZE;
66+
void *s = (void *)__get_free_pages(GFP_KERNEL, irq_pages);
67+
68+
irq_stack[i] = s;
69+
pr_debug("CPU%d IRQ stack at 0x%p - 0x%p\n", i,
70+
irq_stack[i], irq_stack[i] + IRQ_STACK_SIZE);
71+
}
6172
}
6273

6374
#ifdef CONFIG_DEBUG_STACKOVERFLOW

0 commit comments

Comments
 (0)