diff options
author | Hendrik Brueckner <brueckner@linux.vnet.ibm.com> | 2017-12-04 04:56:49 -0500 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2017-12-05 09:02:41 -0500 |
commit | a81c42136604fb660b366d1ff6d9e0969f166413 (patch) | |
tree | cd27b4653c4a647ab3d54f4a9c7f145299c62dcb | |
parent | 618e165b2a8e10765dd2a4f9866d118a474f0faf (diff) |
perf s390: add regs_query_register_offset()
The regs_query_register_offset() helper function converts
register name like "%r0" to an offset of a register in user_pt_regs
It is required by the BPF prologue generator.
The user_pt_regs structure was recently added to "asm/ptrace.h".
Hence, update tools/perf/check-headers.sh to keep the header file
in sync with kernel changes.
Suggested-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Reviewed-and-tested-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r-- | tools/perf/arch/s390/Makefile | 1 | ||||
-rw-r--r-- | tools/perf/arch/s390/util/dwarf-regs.c | 32 | ||||
-rwxr-xr-x | tools/perf/check-headers.sh | 1 |
3 files changed, 31 insertions, 3 deletions
diff --git a/tools/perf/arch/s390/Makefile b/tools/perf/arch/s390/Makefile index 21322e0385b8..09ba923debe8 100644 --- a/tools/perf/arch/s390/Makefile +++ b/tools/perf/arch/s390/Makefile | |||
@@ -2,3 +2,4 @@ ifndef NO_DWARF | |||
2 | PERF_HAVE_DWARF_REGS := 1 | 2 | PERF_HAVE_DWARF_REGS := 1 |
3 | endif | 3 | endif |
4 | HAVE_KVM_STAT_SUPPORT := 1 | 4 | HAVE_KVM_STAT_SUPPORT := 1 |
5 | PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1 | ||
diff --git a/tools/perf/arch/s390/util/dwarf-regs.c b/tools/perf/arch/s390/util/dwarf-regs.c index f47576ce13ea..a8ace5cc6301 100644 --- a/tools/perf/arch/s390/util/dwarf-regs.c +++ b/tools/perf/arch/s390/util/dwarf-regs.c | |||
@@ -2,17 +2,43 @@ | |||
2 | /* | 2 | /* |
3 | * Mapping of DWARF debug register numbers into register names. | 3 | * Mapping of DWARF debug register numbers into register names. |
4 | * | 4 | * |
5 | * Copyright IBM Corp. 2010 | 5 | * Copyright IBM Corp. 2010, 2017 |
6 | * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>, | 6 | * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>, |
7 | * Hendrik Brueckner <brueckner@linux.vnet.ibm.com> | ||
7 | * | 8 | * |
8 | */ | 9 | */ |
9 | 10 | ||
11 | #include <errno.h> | ||
10 | #include <stddef.h> | 12 | #include <stddef.h> |
11 | #include <dwarf-regs.h> | 13 | #include <stdlib.h> |
12 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <asm/ptrace.h> | ||
16 | #include <string.h> | ||
17 | #include <dwarf-regs.h> | ||
13 | #include "dwarf-regs-table.h" | 18 | #include "dwarf-regs-table.h" |
14 | 19 | ||
15 | const char *get_arch_regstr(unsigned int n) | 20 | const char *get_arch_regstr(unsigned int n) |
16 | { | 21 | { |
17 | return (n >= ARRAY_SIZE(s390_dwarf_regs)) ? NULL : s390_dwarf_regs[n]; | 22 | return (n >= ARRAY_SIZE(s390_dwarf_regs)) ? NULL : s390_dwarf_regs[n]; |
18 | } | 23 | } |
24 | |||
25 | /* | ||
26 | * Convert the register name into an offset to struct pt_regs (kernel). | ||
27 | * This is required by the BPF prologue generator. The BPF | ||
28 | * program is called in the BPF overflow handler in the perf | ||
29 | * core. | ||
30 | */ | ||
31 | int regs_query_register_offset(const char *name) | ||
32 | { | ||
33 | unsigned long gpr; | ||
34 | |||
35 | if (!name || strncmp(name, "%r", 2)) | ||
36 | return -EINVAL; | ||
37 | |||
38 | errno = 0; | ||
39 | gpr = strtoul(name + 2, NULL, 10); | ||
40 | if (errno || gpr >= 16) | ||
41 | return -EINVAL; | ||
42 | |||
43 | return offsetof(user_pt_regs, gprs) + 8 * gpr; | ||
44 | } | ||
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh index 77406d25e521..6db9d809fe97 100755 --- a/tools/perf/check-headers.sh +++ b/tools/perf/check-headers.sh | |||
@@ -30,6 +30,7 @@ arch/x86/include/uapi/asm/vmx.h | |||
30 | arch/powerpc/include/uapi/asm/kvm.h | 30 | arch/powerpc/include/uapi/asm/kvm.h |
31 | arch/s390/include/uapi/asm/kvm.h | 31 | arch/s390/include/uapi/asm/kvm.h |
32 | arch/s390/include/uapi/asm/kvm_perf.h | 32 | arch/s390/include/uapi/asm/kvm_perf.h |
33 | arch/s390/include/uapi/asm/ptrace.h | ||
33 | arch/s390/include/uapi/asm/sie.h | 34 | arch/s390/include/uapi/asm/sie.h |
34 | arch/arm/include/uapi/asm/kvm.h | 35 | arch/arm/include/uapi/asm/kvm.h |
35 | arch/arm64/include/uapi/asm/kvm.h | 36 | arch/arm64/include/uapi/asm/kvm.h |