From: Will Deacon Date: Fri, 22 Aug 2014 13:25:21 +0000 (+0100) Subject: arm64: perf: don't rely on layout of pt_regs when grabbing sp or pc X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5b75a6af11357813a7eeb4a29d0261adbbfab556;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git arm64: perf: don't rely on layout of pt_regs when grabbing sp or pc 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 Signed-off-by: Will Deacon --- diff --git a/arch/arm64/kernel/perf_regs.c b/arch/arm64/kernel/perf_regs.c index 422ebd63b619..6762ad705587 100644 --- a/arch/arm64/kernel/perf_regs.c +++ b/arch/arm64/kernel/perf_regs.c @@ -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]; }