arm64: perf: don't rely on layout of pt_regs when grabbing sp or pc
authorWill Deacon <will.deacon@arm.com>
Fri, 22 Aug 2014 13:25:21 +0000 (14:25 +0100)
committerWill Deacon <will.deacon@arm.com>
Thu, 28 Aug 2014 19:01:50 +0000 (20:01 +0100)
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>
arch/arm64/kernel/perf_regs.c

index 422ebd63b619253d23c7a82d5fb14b322dc47fe1..6762ad705587fa34fff0281546273a6930ddbcbf 100644 (file)
@@ -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];
 }
 
This page took 0.02671 seconds and 5 git commands to generate.