aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2014-01-07 07:47:21 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-02-18 07:34:47 -0500
commit3c8b06f981091f91ee603768855e9739a8938296 (patch)
tree0f3e6e58d86952f5f2e0065622069345b0bde936
parentb58f608e31010cb76ee953a6919f9d96b4eb58d9 (diff)
perf tests x86: Introduce perf_regs_load function
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: Jiri Olsa <jolsa@redhat.com> Acked-by: Jean Pihet <jean.pihet@linaro.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: Jean Pihet <jean.pihet@linaro.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/1389098853-14466-5-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/arch/x86/Makefile1
-rw-r--r--tools/perf/arch/x86/include/perf_regs.h2
-rw-r--r--tools/perf/arch/x86/tests/regs_load.S92
3 files changed, 95 insertions, 0 deletions
diff --git a/tools/perf/arch/x86/Makefile b/tools/perf/arch/x86/Makefile
index 8801fe02f206..1cbef7338f84 100644
--- a/tools/perf/arch/x86/Makefile
+++ b/tools/perf/arch/x86/Makefile
@@ -4,6 +4,7 @@ LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
4endif 4endif
5ifndef NO_LIBUNWIND 5ifndef NO_LIBUNWIND
6LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind.o 6LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind.o
7LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/regs_load.o
7endif 8endif
8LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o 9LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o
9LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/tsc.o 10LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/tsc.o
diff --git a/tools/perf/arch/x86/include/perf_regs.h b/tools/perf/arch/x86/include/perf_regs.h
index e84ca76aae77..f3435d62aec1 100644
--- a/tools/perf/arch/x86/include/perf_regs.h
+++ b/tools/perf/arch/x86/include/perf_regs.h
@@ -5,6 +5,8 @@
5#include "../../util/types.h" 5#include "../../util/types.h"
6#include <asm/perf_regs.h> 6#include <asm/perf_regs.h>
7 7
8void perf_regs_load(u64 *regs);
9
8#ifndef HAVE_ARCH_X86_64_SUPPORT 10#ifndef HAVE_ARCH_X86_64_SUPPORT
9#define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1) 11#define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1)
10#else 12#else
diff --git a/tools/perf/arch/x86/tests/regs_load.S b/tools/perf/arch/x86/tests/regs_load.S
new file mode 100644
index 000000000000..99167bf644ea
--- /dev/null
+++ b/tools/perf/arch/x86/tests/regs_load.S
@@ -0,0 +1,92 @@
1
2#include <linux/linkage.h>
3
4#define AX 0
5#define BX 1 * 8
6#define CX 2 * 8
7#define DX 3 * 8
8#define SI 4 * 8
9#define DI 5 * 8
10#define BP 6 * 8
11#define SP 7 * 8
12#define IP 8 * 8
13#define FLAGS 9 * 8
14#define CS 10 * 8
15#define SS 11 * 8
16#define DS 12 * 8
17#define ES 13 * 8
18#define FS 14 * 8
19#define GS 15 * 8
20#define R8 16 * 8
21#define R9 17 * 8
22#define R10 18 * 8
23#define R11 19 * 8
24#define R12 20 * 8
25#define R13 21 * 8
26#define R14 22 * 8
27#define R15 23 * 8
28
29.text
30#ifdef HAVE_ARCH_X86_64_SUPPORT
31ENTRY(perf_regs_load)
32 movq %rax, AX(%rdi)
33 movq %rbx, BX(%rdi)
34 movq %rcx, CX(%rdi)
35 movq %rdx, DX(%rdi)
36 movq %rsi, SI(%rdi)
37 movq %rdi, DI(%rdi)
38 movq %rbp, BP(%rdi)
39
40 leaq 8(%rsp), %rax /* exclude this call. */
41 movq %rax, SP(%rdi)
42
43 movq 0(%rsp), %rax
44 movq %rax, IP(%rdi)
45
46 movq $0, FLAGS(%rdi)
47 movq $0, CS(%rdi)
48 movq $0, SS(%rdi)
49 movq $0, DS(%rdi)
50 movq $0, ES(%rdi)
51 movq $0, FS(%rdi)
52 movq $0, GS(%rdi)
53
54 movq %r8, R8(%rdi)
55 movq %r9, R9(%rdi)
56 movq %r10, R10(%rdi)
57 movq %r11, R11(%rdi)
58 movq %r12, R12(%rdi)
59 movq %r13, R13(%rdi)
60 movq %r14, R14(%rdi)
61 movq %r15, R15(%rdi)
62 ret
63ENDPROC(perf_regs_load)
64#else
65ENTRY(perf_regs_load)
66 push %edi
67 movl 8(%esp), %edi
68 movl %eax, AX(%edi)
69 movl %ebx, BX(%edi)
70 movl %ecx, CX(%edi)
71 movl %edx, DX(%edi)
72 movl %esi, SI(%edi)
73 pop %eax
74 movl %eax, DI(%edi)
75 movl %ebp, BP(%edi)
76
77 leal 4(%esp), %eax /* exclude this call. */
78 movl %eax, SP(%edi)
79
80 movl 0(%esp), %eax
81 movl %eax, IP(%edi)
82
83 movl $0, FLAGS(%edi)
84 movl $0, CS(%edi)
85 movl $0, SS(%edi)
86 movl $0, DS(%edi)
87 movl $0, ES(%edi)
88 movl $0, FS(%edi)
89 movl $0, GS(%edi)
90 ret
91ENDPROC(perf_regs_load)
92#endif