blob: 60875d5c556c217d3433487d65cf66382a78d25b [file] [log] [blame]
Jiri Olsa3c8b06f2014-01-07 13:47:21 +01001#include <linux/linkage.h>
2
3#define AX 0
4#define BX 1 * 8
5#define CX 2 * 8
6#define DX 3 * 8
7#define SI 4 * 8
8#define DI 5 * 8
9#define BP 6 * 8
10#define SP 7 * 8
11#define IP 8 * 8
12#define FLAGS 9 * 8
13#define CS 10 * 8
14#define SS 11 * 8
15#define DS 12 * 8
16#define ES 13 * 8
17#define FS 14 * 8
18#define GS 15 * 8
19#define R8 16 * 8
20#define R9 17 * 8
21#define R10 18 * 8
22#define R11 19 * 8
23#define R12 20 * 8
24#define R13 21 * 8
25#define R14 22 * 8
26#define R15 23 * 8
27
28.text
29#ifdef HAVE_ARCH_X86_64_SUPPORT
30ENTRY(perf_regs_load)
31 movq %rax, AX(%rdi)
32 movq %rbx, BX(%rdi)
33 movq %rcx, CX(%rdi)
34 movq %rdx, DX(%rdi)
35 movq %rsi, SI(%rdi)
36 movq %rdi, DI(%rdi)
37 movq %rbp, BP(%rdi)
38
39 leaq 8(%rsp), %rax /* exclude this call. */
40 movq %rax, SP(%rdi)
41
42 movq 0(%rsp), %rax
43 movq %rax, IP(%rdi)
44
45 movq $0, FLAGS(%rdi)
46 movq $0, CS(%rdi)
47 movq $0, SS(%rdi)
48 movq $0, DS(%rdi)
49 movq $0, ES(%rdi)
50 movq $0, FS(%rdi)
51 movq $0, GS(%rdi)
52
53 movq %r8, R8(%rdi)
54 movq %r9, R9(%rdi)
55 movq %r10, R10(%rdi)
56 movq %r11, R11(%rdi)
57 movq %r12, R12(%rdi)
58 movq %r13, R13(%rdi)
59 movq %r14, R14(%rdi)
60 movq %r15, R15(%rdi)
61 ret
62ENDPROC(perf_regs_load)
63#else
64ENTRY(perf_regs_load)
65 push %edi
66 movl 8(%esp), %edi
67 movl %eax, AX(%edi)
68 movl %ebx, BX(%edi)
69 movl %ecx, CX(%edi)
70 movl %edx, DX(%edi)
71 movl %esi, SI(%edi)
72 pop %eax
73 movl %eax, DI(%edi)
74 movl %ebp, BP(%edi)
75
76 leal 4(%esp), %eax /* exclude this call. */
77 movl %eax, SP(%edi)
78
79 movl 0(%esp), %eax
80 movl %eax, IP(%edi)
81
82 movl $0, FLAGS(%edi)
83 movl $0, CS(%edi)
84 movl $0, SS(%edi)
85 movl $0, DS(%edi)
86 movl $0, ES(%edi)
87 movl $0, FS(%edi)
88 movl $0, GS(%edi)
89 ret
90ENDPROC(perf_regs_load)
91#endif
Mathias Krause6392b4e2014-04-27 18:51:05 +020092
93/*
94 * We need to provide note.GNU-stack section, saying that we want
95 * NOT executable stack. Otherwise the final linking will assume that
96 * the ELF stack should not be restricted at all and set it RWX.
97 */
98.section .note.GNU-stack,"",@progbits