Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools arm64: Add support for generating bpf prologue

Since HAVE_KPROBES can be enabled in arm64, this patch introduces
regs_query_register_offset() to convert register name to offset for
arm64, so the BPF prologue feature is ready to use.

Signed-off-by: He Kuang <hekuang@huawei.com>
Reviewed-by: Will Deacon <will.deacon@arm.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Bintian Wang <bintian.wang@huawei.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/20170207073412.26983-1-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

He Kuang and committed by
Arnaldo Carvalho de Melo
3bb53c9f e06094ab

+15 -1
+1
tools/perf/arch/arm64/Makefile
··· 2 2 PERF_HAVE_DWARF_REGS := 1 3 3 endif 4 4 PERF_HAVE_JITDUMP := 1 5 + PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
+14 -1
tools/perf/arch/arm64/util/dwarf-regs.c
··· 10 10 11 11 #include <stddef.h> 12 12 #include <dwarf-regs.h> 13 + #include <linux/ptrace.h> /* for struct user_pt_regs */ 14 + #include "util.h" 13 15 14 16 struct pt_regs_dwarfnum { 15 17 const char *name; 16 18 unsigned int dwarfnum; 17 19 }; 18 20 19 - #define STR(s) #s 20 21 #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num} 21 22 #define GPR_DWARFNUM_NAME(num) \ 22 23 {.name = STR(%x##num), .dwarfnum = num} 23 24 #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0} 25 + #define DWARFNUM2OFFSET(index) \ 26 + (index * sizeof((struct user_pt_regs *)0)->regs[0]) 24 27 25 28 /* 26 29 * Reference: ··· 80 77 if (roff->dwarfnum == n) 81 78 return roff->name; 82 79 return NULL; 80 + } 81 + 82 + int regs_query_register_offset(const char *name) 83 + { 84 + const struct pt_regs_dwarfnum *roff; 85 + 86 + for (roff = regdwarfnum_table; roff->name != NULL; roff++) 87 + if (!strcmp(roff->name, name)) 88 + return DWARFNUM2OFFSET(roff->dwarfnum); 89 + return -EINVAL; 83 90 }