perf/x86/intel/pt: Clean up the control flow in pt_pmu_hw_init()
[sfrench/cifs-2.6.git] / arch / x86 / lib / thunk_32.S
1 /*
2  * Trampoline to trace irqs off. (otherwise CALLER_ADDR1 might crash)
3  * Copyright 2008 by Steven Rostedt, Red Hat, Inc
4  *  (inspired by Andi Kleen's thunk_64.S)
5  * Subject to the GNU public license, v.2. No warranty of any kind.
6  */
7         #include <linux/linkage.h>
8         #include <asm/asm.h>
9         #include <asm/dwarf2.h>
10
11         /* put return address in eax (arg1) */
12         .macro THUNK name, func, put_ret_addr_in_eax=0
13         .globl \name
14 \name:
15         CFI_STARTPROC
16         pushl_cfi %eax
17         CFI_REL_OFFSET eax, 0
18         pushl_cfi %ecx
19         CFI_REL_OFFSET ecx, 0
20         pushl_cfi %edx
21         CFI_REL_OFFSET edx, 0
22
23         .if \put_ret_addr_in_eax
24         /* Place EIP in the arg1 */
25         movl 3*4(%esp), %eax
26         .endif
27
28         call \func
29         popl_cfi %edx
30         CFI_RESTORE edx
31         popl_cfi %ecx
32         CFI_RESTORE ecx
33         popl_cfi %eax
34         CFI_RESTORE eax
35         ret
36         CFI_ENDPROC
37         _ASM_NOKPROBE(\name)
38         .endm
39
40 #ifdef CONFIG_TRACE_IRQFLAGS
41         THUNK trace_hardirqs_on_thunk,trace_hardirqs_on_caller,1
42         THUNK trace_hardirqs_off_thunk,trace_hardirqs_off_caller,1
43 #endif
44
45 #ifdef CONFIG_PREEMPT
46         THUNK ___preempt_schedule, preempt_schedule
47 #ifdef CONFIG_CONTEXT_TRACKING
48         THUNK ___preempt_schedule_context, preempt_schedule_context
49 #endif
50 #endif
51