Skip to content

Commit

Permalink
parisc/unwind: fix unwinder when CONFIG_64BIT is enabled
Browse files Browse the repository at this point in the history
[ Upstream commit 8e0ba12 ]

With 64 bit kernels unwind_special() is not working because
it compares the pc to the address of the function descriptor.
Add a helper function that compares pc with the dereferenced
address. This fixes all of the backtraces on my c8000. Without
this changes, a lot of backtraces are missing in kdb or the
show-all-tasks command from /proc/sysrq-trigger.

Signed-off-by: Sven Schnelle <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
svenschnelle authored and gregkh committed Nov 18, 2021
1 parent ab7ce95 commit 028459f
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions arch/parisc/kernel/unwind.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <asm/ptrace.h>

#include <asm/unwind.h>
#include <asm/switch_to.h>
#include <asm/sections.h>

/* #define DEBUG 1 */
#ifdef DEBUG
Expand Down Expand Up @@ -203,6 +205,11 @@ int __init unwind_init(void)
return 0;
}

static bool pc_is_kernel_fn(unsigned long pc, void *fn)
{
return (unsigned long)dereference_kernel_function_descriptor(fn) == pc;
}

static int unwind_special(struct unwind_frame_info *info, unsigned long pc, int frame_size)
{
/*
Expand All @@ -221,21 +228,21 @@ static int unwind_special(struct unwind_frame_info *info, unsigned long pc, int
extern void * const _call_on_stack;
#endif /* CONFIG_IRQSTACKS */

if (pc == (unsigned long) &handle_interruption) {
if (pc_is_kernel_fn(pc, handle_interruption)) {
struct pt_regs *regs = (struct pt_regs *)(info->sp - frame_size - PT_SZ_ALGN);
dbg("Unwinding through handle_interruption()\n");
info->prev_sp = regs->gr[30];
info->prev_ip = regs->iaoq[0];
return 1;
}

if (pc == (unsigned long) &ret_from_kernel_thread ||
pc == (unsigned long) &syscall_exit) {
if (pc_is_kernel_fn(pc, ret_from_kernel_thread) ||
pc_is_kernel_fn(pc, syscall_exit)) {
info->prev_sp = info->prev_ip = 0;
return 1;
}

if (pc == (unsigned long) &intr_return) {
if (pc_is_kernel_fn(pc, intr_return)) {
struct pt_regs *regs;

dbg("Found intr_return()\n");
Expand All @@ -246,20 +253,20 @@ static int unwind_special(struct unwind_frame_info *info, unsigned long pc, int
return 1;
}

if (pc == (unsigned long) &_switch_to_ret) {
if (pc_is_kernel_fn(pc, _switch_to) ||
pc_is_kernel_fn(pc, _switch_to_ret)) {
info->prev_sp = info->sp - CALLEE_SAVE_FRAME_SIZE;
info->prev_ip = *(unsigned long *)(info->prev_sp - RP_OFFSET);
return 1;
}

#ifdef CONFIG_IRQSTACKS
if (pc == (unsigned long) &_call_on_stack) {
if (pc_is_kernel_fn(pc, _call_on_stack)) {
info->prev_sp = *(unsigned long *)(info->sp - FRAME_SIZE - REG_SZ);
info->prev_ip = *(unsigned long *)(info->sp - FRAME_SIZE - RP_OFFSET);
return 1;
}
#endif

return 0;
}

Expand Down

0 comments on commit 028459f

Please sign in to comment.