Skip to content

Commit 3363653

Browse files
mpredfearngregkh
authored andcommitted
MIPS: Stack unwinding while on IRQ stack
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.redfearn@imgtec.com> Acked-by: Jason A. Donenfeld <jason@zx2c4.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Adam Buchbinder <adam.buchbinder@gmail.com> Cc: Maciej W. Rozycki <macro@imgtec.com> Cc: Marcin Nowakowski <marcin.nowakowski@imgtec.com> Cc: Chris Metcalf <cmetcalf@mellanox.com> Cc: James Hogan <james.hogan@imgtec.com> Cc: Paul Burton <paul.burton@imgtec.com> Cc: Jiri Slaby <jslaby@suse.cz> Cc: Andrew Morton <akpm@linux-foundation.org> 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 <ralf@linux-mips.org> Signed-off-by: Amit Pundir <amit.pundir@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d8b8b55 commit 3363653

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

arch/mips/kernel/process.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <asm/cpu.h>
3333
#include <asm/dsp.h>
3434
#include <asm/fpu.h>
35+
#include <asm/irq.h>
3536
#include <asm/msa.h>
3637
#include <asm/pgtable.h>
3738
#include <asm/mipsregs.h>
@@ -552,7 +553,19 @@ EXPORT_SYMBOL(unwind_stack_by_address);
552553
unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
553554
unsigned long pc, unsigned long *ra)
554555
{
555-
unsigned long stack_page = (unsigned long)task_stack_page(task);
556+
unsigned long stack_page = 0;
557+
int cpu;
558+
559+
for_each_possible_cpu(cpu) {
560+
if (on_irq_stack(cpu, *sp)) {
561+
stack_page = (unsigned long)irq_stack[cpu];
562+
break;
563+
}
564+
}
565+
566+
if (!stack_page)
567+
stack_page = (unsigned long)task_stack_page(task);
568+
556569
return unwind_stack_by_address(stack_page, sp, pc, ra);
557570
}
558571
#endif

0 commit comments

Comments
 (0)