4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Matt Redfearn <matt.redfe...@imgtec.com>

commit d42d8d106b0275b027c1e8992c42aecf933436ea upstream.

Within unwind stack, check if the stack pointer being unwound is within
the CPU's irq_stack and if so use that page rather than the task's stack
page.

Signed-off-by: Matt Redfearn <matt.redfe...@imgtec.com>
Acked-by: Jason A. Donenfeld <ja...@zx2c4.com>
Cc: Thomas Gleixner <t...@linutronix.de>
Cc: Adam Buchbinder <adam.buchbin...@gmail.com>
Cc: Maciej W. Rozycki <ma...@imgtec.com>
Cc: Marcin Nowakowski <marcin.nowakow...@imgtec.com>
Cc: Chris Metcalf <cmetc...@mellanox.com>
Cc: James Hogan <james.ho...@imgtec.com>
Cc: Paul Burton <paul.bur...@imgtec.com>
Cc: Jiri Slaby <jsl...@suse.cz>
Cc: Andrew Morton <a...@linux-foundation.org>
Cc: linux-m...@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/14741/
Signed-off-by: Ralf Baechle <r...@linux-mips.org>
Signed-off-by: Amit Pundir <amit.pun...@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>

---
 arch/mips/kernel/process.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -33,6 +33,7 @@
 #include <asm/dsemul.h>
 #include <asm/dsp.h>
 #include <asm/fpu.h>
+#include <asm/irq.h>
 #include <asm/msa.h>
 #include <asm/pgtable.h>
 #include <asm/mipsregs.h>
@@ -556,7 +557,19 @@ EXPORT_SYMBOL(unwind_stack_by_address);
 unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
                           unsigned long pc, unsigned long *ra)
 {
-       unsigned long stack_page = (unsigned long)task_stack_page(task);
+       unsigned long stack_page = 0;
+       int cpu;
+
+       for_each_possible_cpu(cpu) {
+               if (on_irq_stack(cpu, *sp)) {
+                       stack_page = (unsigned long)irq_stack[cpu];
+                       break;
+               }
+       }
+
+       if (!stack_page)
+               stack_page = (unsigned long)task_stack_page(task);
+
        return unwind_stack_by_address(stack_page, sp, pc, ra);
 }
 #endif


Reply via email to