From: Matt Redfearn Date: Mon, 19 Dec 2016 14:20:57 +0000 (+0000) Subject: MIPS: Stack unwinding while on IRQ stack X-Git-Tag: Ubuntu-4.10.0-21.23~13 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=05716ffbae2ff7e3750af2e632f42ca971babe75;p=mirror_ubuntu-artful-kernel.git MIPS: Stack unwinding while on IRQ stack BugLink: http://bugs.launchpad.net/bugs/1685140 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 Acked-by: Jason A. Donenfeld Cc: Thomas Gleixner Cc: Adam Buchbinder Cc: Maciej W. Rozycki Cc: Marcin Nowakowski Cc: Chris Metcalf Cc: James Hogan Cc: Paul Burton Cc: Jiri Slaby Cc: Andrew Morton Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/14741/ Signed-off-by: Ralf Baechle Signed-off-by: Amit Pundir Signed-off-by: Greg Kroah-Hartman Signed-off-by: Stefan Bader --- diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index 7d80447e5d03..efa1df52c616 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -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