Skip to content

Commit

Permalink
arm64: perf: don't rely on layout of pt_regs when grabbing sp or pc
Browse files Browse the repository at this point in the history
The current perf_regs code relies on sp and pc sitting just off the end
of the pt_regs->regs array. This is ugly and fragile, so this patch
checks for these register explicitly and returns the appropriate field.

Acked-by: Jean Pihet <jean.pihet@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
  • Loading branch information
Will Deacon committed Aug 28, 2014
1 parent 85487ed commit 5b75a6a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions arch/arm64/kernel/perf_regs.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)
return regs->compat_lr;
}

if ((u32)idx == PERF_REG_ARM64_SP)
return regs->sp;

if ((u32)idx == PERF_REG_ARM64_PC)
return regs->pc;

return regs->regs[idx];
}

Expand Down

0 comments on commit 5b75a6a

Please sign in to comment.