kernel: update kernel 4.9 to 4.9.14
[openwrt/openwrt.git] / target / linux / generic / patches-4.9 / 040-02-MIPS-Stack-unwinding-while-on-IRQ-stack.patch
1 From: Matt Redfearn <matt.redfearn@imgtec.com>
2 Date: Mon, 19 Dec 2016 14:20:57 +0000
3 Subject: [PATCH] MIPS: Stack unwinding while on IRQ stack
4
5 Within unwind stack, check if the stack pointer being unwound is within
6 the CPU's irq_stack and if so use that page rather than the task's stack
7 page.
8
9 Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
10 ---
11
12 --- a/arch/mips/kernel/process.c
13 +++ b/arch/mips/kernel/process.c
14 @@ -33,6 +33,7 @@
15 #include <asm/dsemul.h>
16 #include <asm/dsp.h>
17 #include <asm/fpu.h>
18 +#include <asm/irq.h>
19 #include <asm/msa.h>
20 #include <asm/pgtable.h>
21 #include <asm/mipsregs.h>
22 @@ -556,7 +557,19 @@ EXPORT_SYMBOL(unwind_stack_by_address);
23 unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
24 unsigned long pc, unsigned long *ra)
25 {
26 - unsigned long stack_page = (unsigned long)task_stack_page(task);
27 + unsigned long stack_page = 0;
28 + int cpu;
29 +
30 + for_each_possible_cpu(cpu) {
31 + if (on_irq_stack(cpu, *sp)) {
32 + stack_page = (unsigned long)irq_stack[cpu];
33 + break;
34 + }
35 + }
36 +
37 + if (!stack_page)
38 + stack_page = (unsigned long)task_stack_page(task);
39 +
40 return unwind_stack_by_address(stack_page, sp, pc, ra);
41 }
42 #endif