diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-09 16:28:26 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-09 16:28:26 -0400 |
| commit | b1e76c3d3a774298475622bde63010972c9515a1 (patch) | |
| tree | 33d5560c184464cfe9f9ba755b761686c8d59290 | |
| parent | 800c608c976c3f0a6d02ed7fbc600f1f6962ac73 (diff) | |
| parent | 3213486f2e442831e324cc6201a2f9e924ecc235 (diff) | |
Merge tag 'csky-for-linus-5.2-perf-unwind-libdw' of git://github.com/c-sky/csky-linux
Pull arch/csky perf update from Guo Ren:
"Add support for perf unwind-libdw"
* tag 'csky-for-linus-5.2-perf-unwind-libdw' of git://github.com/c-sky/csky-linux:
csky: Add support for perf unwind-libdw
| -rw-r--r-- | tools/arch/csky/include/uapi/asm/perf_regs.h | 51 | ||||
| -rw-r--r-- | tools/perf/Makefile.config | 6 | ||||
| -rw-r--r-- | tools/perf/arch/csky/Build | 1 | ||||
| -rw-r--r-- | tools/perf/arch/csky/Makefile | 3 | ||||
| -rw-r--r-- | tools/perf/arch/csky/include/perf_regs.h | 100 | ||||
| -rw-r--r-- | tools/perf/arch/csky/util/Build | 2 | ||||
| -rw-r--r-- | tools/perf/arch/csky/util/dwarf-regs.c | 49 | ||||
| -rw-r--r-- | tools/perf/arch/csky/util/unwind-libdw.c | 77 |
8 files changed, 288 insertions, 1 deletions
diff --git a/tools/arch/csky/include/uapi/asm/perf_regs.h b/tools/arch/csky/include/uapi/asm/perf_regs.h new file mode 100644 index 000000000000..ee323d818592 --- /dev/null +++ b/tools/arch/csky/include/uapi/asm/perf_regs.h | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | // Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. | ||
| 3 | |||
| 4 | #ifndef _ASM_CSKY_PERF_REGS_H | ||
| 5 | #define _ASM_CSKY_PERF_REGS_H | ||
| 6 | |||
| 7 | /* Index of struct pt_regs */ | ||
| 8 | enum perf_event_csky_regs { | ||
| 9 | PERF_REG_CSKY_TLS, | ||
| 10 | PERF_REG_CSKY_LR, | ||
| 11 | PERF_REG_CSKY_PC, | ||
| 12 | PERF_REG_CSKY_SR, | ||
| 13 | PERF_REG_CSKY_SP, | ||
| 14 | PERF_REG_CSKY_ORIG_A0, | ||
| 15 | PERF_REG_CSKY_A0, | ||
| 16 | PERF_REG_CSKY_A1, | ||
| 17 | PERF_REG_CSKY_A2, | ||
| 18 | PERF_REG_CSKY_A3, | ||
| 19 | PERF_REG_CSKY_REGS0, | ||
| 20 | PERF_REG_CSKY_REGS1, | ||
| 21 | PERF_REG_CSKY_REGS2, | ||
| 22 | PERF_REG_CSKY_REGS3, | ||
| 23 | PERF_REG_CSKY_REGS4, | ||
| 24 | PERF_REG_CSKY_REGS5, | ||
| 25 | PERF_REG_CSKY_REGS6, | ||
| 26 | PERF_REG_CSKY_REGS7, | ||
| 27 | PERF_REG_CSKY_REGS8, | ||
| 28 | PERF_REG_CSKY_REGS9, | ||
| 29 | #if defined(__CSKYABIV2__) | ||
| 30 | PERF_REG_CSKY_EXREGS0, | ||
| 31 | PERF_REG_CSKY_EXREGS1, | ||
| 32 | PERF_REG_CSKY_EXREGS2, | ||
| 33 | PERF_REG_CSKY_EXREGS3, | ||
| 34 | PERF_REG_CSKY_EXREGS4, | ||
| 35 | PERF_REG_CSKY_EXREGS5, | ||
| 36 | PERF_REG_CSKY_EXREGS6, | ||
| 37 | PERF_REG_CSKY_EXREGS7, | ||
| 38 | PERF_REG_CSKY_EXREGS8, | ||
| 39 | PERF_REG_CSKY_EXREGS9, | ||
| 40 | PERF_REG_CSKY_EXREGS10, | ||
| 41 | PERF_REG_CSKY_EXREGS11, | ||
| 42 | PERF_REG_CSKY_EXREGS12, | ||
| 43 | PERF_REG_CSKY_EXREGS13, | ||
| 44 | PERF_REG_CSKY_EXREGS14, | ||
| 45 | PERF_REG_CSKY_HI, | ||
| 46 | PERF_REG_CSKY_LO, | ||
| 47 | PERF_REG_CSKY_DCSR, | ||
| 48 | #endif | ||
| 49 | PERF_REG_CSKY_MAX, | ||
| 50 | }; | ||
| 51 | #endif /* _ASM_CSKY_PERF_REGS_H */ | ||
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 0c52a01dc759..e1bb5288ab1f 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config | |||
| @@ -59,6 +59,10 @@ ifeq ($(SRCARCH),arm64) | |||
| 59 | LIBUNWIND_LIBS = -lunwind -lunwind-aarch64 | 59 | LIBUNWIND_LIBS = -lunwind -lunwind-aarch64 |
| 60 | endif | 60 | endif |
| 61 | 61 | ||
| 62 | ifeq ($(SRCARCH),csky) | ||
| 63 | NO_PERF_REGS := 0 | ||
| 64 | endif | ||
| 65 | |||
| 62 | ifeq ($(ARCH),s390) | 66 | ifeq ($(ARCH),s390) |
| 63 | NO_PERF_REGS := 0 | 67 | NO_PERF_REGS := 0 |
| 64 | NO_SYSCALL_TABLE := 0 | 68 | NO_SYSCALL_TABLE := 0 |
| @@ -77,7 +81,7 @@ endif | |||
| 77 | # Disable it on all other architectures in case libdw unwind | 81 | # Disable it on all other architectures in case libdw unwind |
| 78 | # support is detected in system. Add supported architectures | 82 | # support is detected in system. Add supported architectures |
| 79 | # to the check. | 83 | # to the check. |
| 80 | ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390)) | 84 | ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky)) |
| 81 | NO_LIBDW_DWARF_UNWIND := 1 | 85 | NO_LIBDW_DWARF_UNWIND := 1 |
| 82 | endif | 86 | endif |
| 83 | 87 | ||
diff --git a/tools/perf/arch/csky/Build b/tools/perf/arch/csky/Build new file mode 100644 index 000000000000..e4e5f33c84d8 --- /dev/null +++ b/tools/perf/arch/csky/Build | |||
| @@ -0,0 +1 @@ | |||
| perf-y += util/ | |||
diff --git a/tools/perf/arch/csky/Makefile b/tools/perf/arch/csky/Makefile new file mode 100644 index 000000000000..7fbca175099e --- /dev/null +++ b/tools/perf/arch/csky/Makefile | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | ifndef NO_DWARF | ||
| 2 | PERF_HAVE_DWARF_REGS := 1 | ||
| 3 | endif | ||
diff --git a/tools/perf/arch/csky/include/perf_regs.h b/tools/perf/arch/csky/include/perf_regs.h new file mode 100644 index 000000000000..8f336ea1161a --- /dev/null +++ b/tools/perf/arch/csky/include/perf_regs.h | |||
| @@ -0,0 +1,100 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | // Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. | ||
| 3 | |||
| 4 | #ifndef ARCH_PERF_REGS_H | ||
| 5 | #define ARCH_PERF_REGS_H | ||
| 6 | |||
| 7 | #include <stdlib.h> | ||
| 8 | #include <linux/types.h> | ||
| 9 | #include <asm/perf_regs.h> | ||
| 10 | |||
| 11 | #define PERF_REGS_MASK ((1ULL << PERF_REG_CSKY_MAX) - 1) | ||
| 12 | #define PERF_REGS_MAX PERF_REG_CSKY_MAX | ||
| 13 | #define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32 | ||
| 14 | |||
| 15 | #define PERF_REG_IP PERF_REG_CSKY_PC | ||
| 16 | #define PERF_REG_SP PERF_REG_CSKY_SP | ||
| 17 | |||
| 18 | static inline const char *perf_reg_name(int id) | ||
| 19 | { | ||
| 20 | switch (id) { | ||
| 21 | case PERF_REG_CSKY_A0: | ||
| 22 | return "a0"; | ||
| 23 | case PERF_REG_CSKY_A1: | ||
| 24 | return "a1"; | ||
| 25 | case PERF_REG_CSKY_A2: | ||
| 26 | return "a2"; | ||
| 27 | case PERF_REG_CSKY_A3: | ||
| 28 | return "a3"; | ||
| 29 | case PERF_REG_CSKY_REGS0: | ||
| 30 | return "regs0"; | ||
| 31 | case PERF_REG_CSKY_REGS1: | ||
| 32 | return "regs1"; | ||
| 33 | case PERF_REG_CSKY_REGS2: | ||
| 34 | return "regs2"; | ||
| 35 | case PERF_REG_CSKY_REGS3: | ||
| 36 | return "regs3"; | ||
| 37 | case PERF_REG_CSKY_REGS4: | ||
| 38 | return "regs4"; | ||
| 39 | case PERF_REG_CSKY_REGS5: | ||
| 40 | return "regs5"; | ||
| 41 | case PERF_REG_CSKY_REGS6: | ||
| 42 | return "regs6"; | ||
| 43 | case PERF_REG_CSKY_REGS7: | ||
| 44 | return "regs7"; | ||
| 45 | case PERF_REG_CSKY_REGS8: | ||
| 46 | return "regs8"; | ||
| 47 | case PERF_REG_CSKY_REGS9: | ||
| 48 | return "regs9"; | ||
| 49 | case PERF_REG_CSKY_SP: | ||
| 50 | return "sp"; | ||
| 51 | case PERF_REG_CSKY_LR: | ||
| 52 | return "lr"; | ||
| 53 | case PERF_REG_CSKY_PC: | ||
| 54 | return "pc"; | ||
| 55 | #if defined(__CSKYABIV2__) | ||
| 56 | case PERF_REG_CSKY_EXREGS0: | ||
| 57 | return "exregs0"; | ||
| 58 | case PERF_REG_CSKY_EXREGS1: | ||
| 59 | return "exregs1"; | ||
| 60 | case PERF_REG_CSKY_EXREGS2: | ||
| 61 | return "exregs2"; | ||
| 62 | case PERF_REG_CSKY_EXREGS3: | ||
| 63 | return "exregs3"; | ||
| 64 | case PERF_REG_CSKY_EXREGS4: | ||
| 65 | return "exregs4"; | ||
| 66 | case PERF_REG_CSKY_EXREGS5: | ||
| 67 | return "exregs5"; | ||
| 68 | case PERF_REG_CSKY_EXREGS6: | ||
| 69 | return "exregs6"; | ||
| 70 | case PERF_REG_CSKY_EXREGS7: | ||
| 71 | return "exregs7"; | ||
| 72 | case PERF_REG_CSKY_EXREGS8: | ||
| 73 | return "exregs8"; | ||
| 74 | case PERF_REG_CSKY_EXREGS9: | ||
| 75 | return "exregs9"; | ||
| 76 | case PERF_REG_CSKY_EXREGS10: | ||
| 77 | return "exregs10"; | ||
| 78 | case PERF_REG_CSKY_EXREGS11: | ||
| 79 | return "exregs11"; | ||
| 80 | case PERF_REG_CSKY_EXREGS12: | ||
| 81 | return "exregs12"; | ||
| 82 | case PERF_REG_CSKY_EXREGS13: | ||
| 83 | return "exregs13"; | ||
| 84 | case PERF_REG_CSKY_EXREGS14: | ||
| 85 | return "exregs14"; | ||
| 86 | case PERF_REG_CSKY_TLS: | ||
| 87 | return "tls"; | ||
| 88 | case PERF_REG_CSKY_HI: | ||
| 89 | return "hi"; | ||
| 90 | case PERF_REG_CSKY_LO: | ||
| 91 | return "lo"; | ||
| 92 | #endif | ||
| 93 | default: | ||
| 94 | return NULL; | ||
| 95 | } | ||
| 96 | |||
| 97 | return NULL; | ||
| 98 | } | ||
| 99 | |||
| 100 | #endif /* ARCH_PERF_REGS_H */ | ||
diff --git a/tools/perf/arch/csky/util/Build b/tools/perf/arch/csky/util/Build new file mode 100644 index 000000000000..1160bb2332ba --- /dev/null +++ b/tools/perf/arch/csky/util/Build | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | perf-$(CONFIG_DWARF) += dwarf-regs.o | ||
| 2 | perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o | ||
diff --git a/tools/perf/arch/csky/util/dwarf-regs.c b/tools/perf/arch/csky/util/dwarf-regs.c new file mode 100644 index 000000000000..ca86ecaeacbb --- /dev/null +++ b/tools/perf/arch/csky/util/dwarf-regs.c | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. | ||
| 3 | // Mapping of DWARF debug register numbers into register names. | ||
| 4 | |||
| 5 | #include <stddef.h> | ||
| 6 | #include <dwarf-regs.h> | ||
| 7 | |||
| 8 | #if defined(__CSKYABIV2__) | ||
| 9 | #define CSKY_MAX_REGS 73 | ||
| 10 | const char *csky_dwarf_regs_table[CSKY_MAX_REGS] = { | ||
| 11 | /* r0 ~ r8 */ | ||
| 12 | "%a0", "%a1", "%a2", "%a3", "%regs0", "%regs1", "%regs2", "%regs3", | ||
| 13 | /* r9 ~ r15 */ | ||
| 14 | "%regs4", "%regs5", "%regs6", "%regs7", "%regs8", "%regs9", "%sp", | ||
| 15 | "%lr", | ||
| 16 | /* r16 ~ r23 */ | ||
| 17 | "%exregs0", "%exregs1", "%exregs2", "%exregs3", "%exregs4", | ||
| 18 | "%exregs5", "%exregs6", "%exregs7", | ||
| 19 | /* r24 ~ r31 */ | ||
| 20 | "%exregs8", "%exregs9", "%exregs10", "%exregs11", "%exregs12", | ||
| 21 | "%exregs13", "%exregs14", "%tls", | ||
| 22 | "%pc", NULL, NULL, NULL, "%hi", "%lo", NULL, NULL, | ||
| 23 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | ||
| 24 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | ||
| 25 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | ||
| 26 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | ||
| 27 | "%epc", | ||
| 28 | }; | ||
| 29 | #else | ||
| 30 | #define CSKY_MAX_REGS 57 | ||
| 31 | const char *csky_dwarf_regs_table[CSKY_MAX_REGS] = { | ||
| 32 | /* r0 ~ r8 */ | ||
| 33 | "%sp", "%regs9", "%a0", "%a1", "%a2", "%a3", "%regs0", "%regs1", | ||
| 34 | /* r9 ~ r15 */ | ||
| 35 | "%regs2", "%regs3", "%regs4", "%regs5", "%regs6", "%regs7", "%regs8", | ||
| 36 | "%lr", | ||
| 37 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | ||
| 38 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | ||
| 39 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | ||
| 40 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | ||
| 41 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | ||
| 42 | "%epc", | ||
| 43 | }; | ||
| 44 | #endif | ||
| 45 | |||
| 46 | const char *get_arch_regstr(unsigned int n) | ||
| 47 | { | ||
| 48 | return (n < CSKY_MAX_REGS) ? csky_dwarf_regs_table[n] : NULL; | ||
| 49 | } | ||
diff --git a/tools/perf/arch/csky/util/unwind-libdw.c b/tools/perf/arch/csky/util/unwind-libdw.c new file mode 100644 index 000000000000..4bb4a06776e4 --- /dev/null +++ b/tools/perf/arch/csky/util/unwind-libdw.c | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | // Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. | ||
| 3 | |||
| 4 | #include <elfutils/libdwfl.h> | ||
| 5 | #include "../../util/unwind-libdw.h" | ||
| 6 | #include "../../util/perf_regs.h" | ||
| 7 | #include "../../util/event.h" | ||
| 8 | |||
| 9 | bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg) | ||
| 10 | { | ||
| 11 | struct unwind_info *ui = arg; | ||
| 12 | struct regs_dump *user_regs = &ui->sample->user_regs; | ||
| 13 | Dwarf_Word dwarf_regs[PERF_REG_CSKY_MAX]; | ||
| 14 | |||
| 15 | #define REG(r) ({ \ | ||
| 16 | Dwarf_Word val = 0; \ | ||
| 17 | perf_reg_value(&val, user_regs, PERF_REG_CSKY_##r); \ | ||
| 18 | val; \ | ||
| 19 | }) | ||
| 20 | |||
| 21 | #if defined(__CSKYABIV2__) | ||
| 22 | dwarf_regs[0] = REG(A0); | ||
| 23 | dwarf_regs[1] = REG(A1); | ||
| 24 | dwarf_regs[2] = REG(A2); | ||
| 25 | dwarf_regs[3] = REG(A3); | ||
| 26 | dwarf_regs[4] = REG(REGS0); | ||
| 27 | dwarf_regs[5] = REG(REGS1); | ||
| 28 | dwarf_regs[6] = REG(REGS2); | ||
| 29 | dwarf_regs[7] = REG(REGS3); | ||
| 30 | dwarf_regs[8] = REG(REGS4); | ||
| 31 | dwarf_regs[9] = REG(REGS5); | ||
| 32 | dwarf_regs[10] = REG(REGS6); | ||
| 33 | dwarf_regs[11] = REG(REGS7); | ||
| 34 | dwarf_regs[12] = REG(REGS8); | ||
| 35 | dwarf_regs[13] = REG(REGS9); | ||
| 36 | dwarf_regs[14] = REG(SP); | ||
| 37 | dwarf_regs[15] = REG(LR); | ||
| 38 | dwarf_regs[16] = REG(EXREGS0); | ||
| 39 | dwarf_regs[17] = REG(EXREGS1); | ||
| 40 | dwarf_regs[18] = REG(EXREGS2); | ||
| 41 | dwarf_regs[19] = REG(EXREGS3); | ||
| 42 | dwarf_regs[20] = REG(EXREGS4); | ||
| 43 | dwarf_regs[21] = REG(EXREGS5); | ||
| 44 | dwarf_regs[22] = REG(EXREGS6); | ||
| 45 | dwarf_regs[23] = REG(EXREGS7); | ||
| 46 | dwarf_regs[24] = REG(EXREGS8); | ||
| 47 | dwarf_regs[25] = REG(EXREGS9); | ||
| 48 | dwarf_regs[26] = REG(EXREGS10); | ||
| 49 | dwarf_regs[27] = REG(EXREGS11); | ||
| 50 | dwarf_regs[28] = REG(EXREGS12); | ||
| 51 | dwarf_regs[29] = REG(EXREGS13); | ||
| 52 | dwarf_regs[30] = REG(EXREGS14); | ||
| 53 | dwarf_regs[31] = REG(TLS); | ||
| 54 | dwarf_regs[32] = REG(PC); | ||
| 55 | #else | ||
| 56 | dwarf_regs[0] = REG(SP); | ||
| 57 | dwarf_regs[1] = REG(REGS9); | ||
| 58 | dwarf_regs[2] = REG(A0); | ||
| 59 | dwarf_regs[3] = REG(A1); | ||
| 60 | dwarf_regs[4] = REG(A2); | ||
| 61 | dwarf_regs[5] = REG(A3); | ||
| 62 | dwarf_regs[6] = REG(REGS0); | ||
| 63 | dwarf_regs[7] = REG(REGS1); | ||
| 64 | dwarf_regs[8] = REG(REGS2); | ||
| 65 | dwarf_regs[9] = REG(REGS3); | ||
| 66 | dwarf_regs[10] = REG(REGS4); | ||
| 67 | dwarf_regs[11] = REG(REGS5); | ||
| 68 | dwarf_regs[12] = REG(REGS6); | ||
| 69 | dwarf_regs[13] = REG(REGS7); | ||
| 70 | dwarf_regs[14] = REG(REGS8); | ||
| 71 | dwarf_regs[15] = REG(LR); | ||
| 72 | #endif | ||
| 73 | dwfl_thread_state_register_pc(thread, REG(PC)); | ||
| 74 | |||
| 75 | return dwfl_thread_state_registers(thread, 0, PERF_REG_CSKY_MAX, | ||
| 76 | dwarf_regs); | ||
| 77 | } | ||
