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

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>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
3c8b06f9 b58f608e

+95
+1
tools/perf/arch/x86/Makefile
··· 4 4 endif 5 5 ifndef NO_LIBUNWIND 6 6 LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind.o 7 + LIB_OBJS += $(OUTPUT)arch/$(ARCH)/tests/regs_load.o 7 8 endif 8 9 LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o 9 10 LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/tsc.o
+2
tools/perf/arch/x86/include/perf_regs.h
··· 5 5 #include "../../util/types.h" 6 6 #include <asm/perf_regs.h> 7 7 8 + void perf_regs_load(u64 *regs); 9 + 8 10 #ifndef HAVE_ARCH_X86_64_SUPPORT 9 11 #define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1) 10 12 #else
+92
tools/perf/arch/x86/tests/regs_load.S
··· 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 31 + ENTRY(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 63 + ENDPROC(perf_regs_load) 64 + #else 65 + ENTRY(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 91 + ENDPROC(perf_regs_load) 92 + #endif