Commit | Line | Data |
---|---|---|
3f520cd2 | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
cc1e684a AK |
2 | /* |
3 | * Save registers before calling assembly functions. This avoids | |
4 | * disturbance of register allocation in some inline assembly constructs. | |
5 | * Copyright 2001,2002 by Andi Kleen, SuSE Labs. | |
81d68a96 | 6 | * Added trace_hardirqs callers - Copyright 2007 Steven Rostedt, Red Hat, Inc. |
cc1e684a | 7 | */ |
38e6b75d | 8 | #include <linux/linkage.h> |
d36f9479 | 9 | #include "calling.h" |
98def1de | 10 | #include <asm/asm.h> |
784d5699 | 11 | #include <asm/export.h> |
1da177e4 | 12 | |
38e6b75d BP |
13 | /* rdi: arg1 ... normal C conventions. rax is saved/restored. */ |
14 | .macro THUNK name, func, put_ret_addr_in_rdi=0 | |
e6dd4739 | 15 | ENTRY(\name) |
d4bf7078 JP |
16 | pushq %rbp |
17 | movq %rsp, %rbp | |
38e6b75d | 18 | |
131484c8 IM |
19 | pushq %rdi |
20 | pushq %rsi | |
21 | pushq %rdx | |
22 | pushq %rcx | |
23 | pushq %rax | |
24 | pushq %r8 | |
25 | pushq %r9 | |
26 | pushq %r10 | |
27 | pushq %r11 | |
38e6b75d BP |
28 | |
29 | .if \put_ret_addr_in_rdi | |
d4bf7078 JP |
30 | /* 8(%rbp) is return addr on stack */ |
31 | movq 8(%rbp), %rdi | |
38e6b75d BP |
32 | .endif |
33 | ||
81d68a96 | 34 | call \func |
9a7e7b57 | 35 | jmp .L_restore |
e6dd4739 | 36 | ENDPROC(\name) |
98def1de | 37 | _ASM_NOKPROBE(\name) |
81d68a96 SR |
38 | .endm |
39 | ||
38e6b75d BP |
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 | |
6375e2b7 | 43 | #endif |
10cd706d PZ |
44 | |
45 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | |
38e6b75d | 46 | THUNK lockdep_sys_exit_thunk,lockdep_sys_exit |
10cd706d | 47 | #endif |
38e6b75d | 48 | |
48593975 | 49 | #ifdef CONFIG_PREEMPTION |
0ad6e3c5 | 50 | THUNK ___preempt_schedule, preempt_schedule |
4eaca0a8 | 51 | THUNK ___preempt_schedule_notrace, preempt_schedule_notrace |
784d5699 AV |
52 | EXPORT_SYMBOL(___preempt_schedule) |
53 | EXPORT_SYMBOL(___preempt_schedule_notrace) | |
0ad6e3c5 ON |
54 | #endif |
55 | ||
69e8544c DV |
56 | #if defined(CONFIG_TRACE_IRQFLAGS) \ |
57 | || defined(CONFIG_DEBUG_LOCK_ALLOC) \ | |
48593975 | 58 | || defined(CONFIG_PREEMPTION) |
9a7e7b57 | 59 | .L_restore: |
131484c8 IM |
60 | popq %r11 |
61 | popq %r10 | |
62 | popq %r9 | |
63 | popq %r8 | |
64 | popq %rax | |
65 | popq %rcx | |
66 | popq %rdx | |
67 | popq %rsi | |
68 | popq %rdi | |
d4bf7078 | 69 | popq %rbp |
38e6b75d | 70 | ret |
9a7e7b57 | 71 | _ASM_NOKPROBE(.L_restore) |
69e8544c | 72 | #endif |