diff options
| author | Jean Pihet <jean.pihet@linaro.org> | 2014-05-16 04:41:10 -0400 |
|---|---|---|
| committer | Jiri Olsa <jolsa@kernel.org> | 2014-05-16 05:39:05 -0400 |
| commit | 3418f9667e8cc4070a86215e6c12baa5bc2f2799 (patch) | |
| tree | 0846efe3d5fb6f62ec233d852ee95eed66f812cc | |
| parent | 21a8b756b84ecaa0b7f29199669c151e2ce5e723 (diff) | |
perf tests: Introduce perf_regs_load function on ARM
Introducing perf_regs_load function, which is going
to be used for dwarf unwind test in following patches.
It takes single argument as a pointer to the regs dump
buffer and populates it with current registers values.
Signed-off-by: Jean Pihet <jean.pihet@linaro.org>
Reviewed-by: Will Deacon <will.deacon@arm.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1400229672-16104-2-git-send-email-jean.pihet@linaro.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
| -rw-r--r-- | tools/perf/arch/arm/Makefile | 1 | ||||
| -rw-r--r-- | tools/perf/arch/arm/include/perf_regs.h | 2 | ||||
| -rw-r--r-- | tools/perf/arch/arm/tests/regs_load.S | 58 |
3 files changed, 61 insertions, 0 deletions
diff --git a/tools/perf/arch/arm/Makefile b/tools/perf/arch/arm/Makefile index 67e9b3d38e89..9b8f87e8c7b9 100644 --- a/tools/perf/arch/arm/Makefile +++ b/tools/perf/arch/arm/Makefile | |||
| @@ -4,4 +4,5 @@ LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o | |||
| 4 | endif | 4 | endif |
| 5 | ifndef NO_LIBUNWIND | 5 | ifndef NO_LIBUNWIND |
| 6 | LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind-libunwind.o | 6 | LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind-libunwind.o |
| 7 | LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/regs_load.o | ||
| 7 | endif | 8 | endif |
diff --git a/tools/perf/arch/arm/include/perf_regs.h b/tools/perf/arch/arm/include/perf_regs.h index bcca511f5884..33abcfa3057c 100644 --- a/tools/perf/arch/arm/include/perf_regs.h +++ b/tools/perf/arch/arm/include/perf_regs.h | |||
| @@ -5,6 +5,8 @@ | |||
| 5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
| 6 | #include <asm/perf_regs.h> | 6 | #include <asm/perf_regs.h> |
| 7 | 7 | ||
| 8 | void perf_regs_load(u64 *regs); | ||
| 9 | |||
| 8 | #define PERF_REGS_MASK ((1ULL << PERF_REG_ARM_MAX) - 1) | 10 | #define PERF_REGS_MASK ((1ULL << PERF_REG_ARM_MAX) - 1) |
| 9 | #define PERF_REG_IP PERF_REG_ARM_PC | 11 | #define PERF_REG_IP PERF_REG_ARM_PC |
| 10 | #define PERF_REG_SP PERF_REG_ARM_SP | 12 | #define PERF_REG_SP PERF_REG_ARM_SP |
diff --git a/tools/perf/arch/arm/tests/regs_load.S b/tools/perf/arch/arm/tests/regs_load.S new file mode 100644 index 000000000000..e09e983946fe --- /dev/null +++ b/tools/perf/arch/arm/tests/regs_load.S | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | #include <linux/linkage.h> | ||
| 2 | |||
| 3 | #define R0 0x00 | ||
| 4 | #define R1 0x08 | ||
| 5 | #define R2 0x10 | ||
| 6 | #define R3 0x18 | ||
| 7 | #define R4 0x20 | ||
| 8 | #define R5 0x28 | ||
| 9 | #define R6 0x30 | ||
| 10 | #define R7 0x38 | ||
| 11 | #define R8 0x40 | ||
| 12 | #define R9 0x48 | ||
| 13 | #define SL 0x50 | ||
| 14 | #define FP 0x58 | ||
| 15 | #define IP 0x60 | ||
| 16 | #define SP 0x68 | ||
| 17 | #define LR 0x70 | ||
| 18 | #define PC 0x78 | ||
| 19 | |||
| 20 | /* | ||
| 21 | * Implementation of void perf_regs_load(u64 *regs); | ||
| 22 | * | ||
| 23 | * This functions fills in the 'regs' buffer from the actual registers values, | ||
| 24 | * in the way the perf built-in unwinding test expects them: | ||
| 25 | * - the PC at the time at the call to this function. Since this function | ||
| 26 | * is called using a bl instruction, the PC value is taken from LR. | ||
| 27 | * The built-in unwinding test then unwinds the call stack from the dwarf | ||
| 28 | * information in unwind__get_entries. | ||
| 29 | * | ||
| 30 | * Notes: | ||
| 31 | * - the 8 bytes stride in the registers offsets comes from the fact | ||
| 32 | * that the registers are stored in an u64 array (u64 *regs), | ||
| 33 | * - the regs buffer needs to be zeroed before the call to this function, | ||
| 34 | * in this case using a calloc in dwarf-unwind.c. | ||
| 35 | */ | ||
| 36 | |||
| 37 | .text | ||
| 38 | .type perf_regs_load,%function | ||
| 39 | ENTRY(perf_regs_load) | ||
| 40 | str r0, [r0, #R0] | ||
| 41 | str r1, [r0, #R1] | ||
| 42 | str r2, [r0, #R2] | ||
| 43 | str r3, [r0, #R3] | ||
| 44 | str r4, [r0, #R4] | ||
| 45 | str r5, [r0, #R5] | ||
| 46 | str r6, [r0, #R6] | ||
| 47 | str r7, [r0, #R7] | ||
| 48 | str r8, [r0, #R8] | ||
| 49 | str r9, [r0, #R9] | ||
| 50 | str sl, [r0, #SL] | ||
| 51 | str fp, [r0, #FP] | ||
| 52 | str ip, [r0, #IP] | ||
| 53 | str sp, [r0, #SP] | ||
| 54 | str lr, [r0, #LR] | ||
| 55 | str lr, [r0, #PC] // store pc as lr in order to skip the call | ||
| 56 | // to this function | ||
| 57 | mov pc, lr | ||
| 58 | ENDPROC(perf_regs_load) | ||
