thunk_64.S 1.5 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0-only */
2 3 4 5
/*
 * Save registers before calling assembly functions. This avoids
 * disturbance of register allocation in some inline assembly constructs.
 * Copyright 2001,2002 by Andi Kleen, SuSE Labs.
6
 * Added trace_hardirqs callers - Copyright 2007 Steven Rostedt, Red Hat, Inc.
7
 */
B
Borislav Petkov 已提交
8
#include <linux/linkage.h>
9
#include "calling.h"
10
#include <asm/asm.h>
11
#include <asm/export.h>
L
Linus Torvalds 已提交
12

B
Borislav Petkov 已提交
13 14
	/* rdi:	arg1 ... normal C conventions. rax is saved/restored. */
	.macro THUNK name, func, put_ret_addr_in_rdi=0
15
	ENTRY(\name)
16 17
	pushq %rbp
	movq %rsp, %rbp
B
Borislav Petkov 已提交
18

19 20 21 22 23 24 25 26 27
	pushq %rdi
	pushq %rsi
	pushq %rdx
	pushq %rcx
	pushq %rax
	pushq %r8
	pushq %r9
	pushq %r10
	pushq %r11
B
Borislav Petkov 已提交
28 29

	.if \put_ret_addr_in_rdi
30 31
	/* 8(%rbp) is return addr on stack */
	movq 8(%rbp), %rdi
B
Borislav Petkov 已提交
32 33
	.endif

34
	call \func
35
	jmp  .L_restore
36
	ENDPROC(\name)
37
	_ASM_NOKPROBE(\name)
38 39
	.endm

B
Borislav Petkov 已提交
40 41 42
#ifdef CONFIG_TRACE_IRQFLAGS
	THUNK trace_hardirqs_on_thunk,trace_hardirqs_on_caller,1
	THUNK trace_hardirqs_off_thunk,trace_hardirqs_off_caller,1
43
#endif
44 45

#ifdef CONFIG_DEBUG_LOCK_ALLOC
B
Borislav Petkov 已提交
46
	THUNK lockdep_sys_exit_thunk,lockdep_sys_exit
47
#endif
B
Borislav Petkov 已提交
48

49 50
#ifdef CONFIG_PREEMPT
	THUNK ___preempt_schedule, preempt_schedule
51
	THUNK ___preempt_schedule_notrace, preempt_schedule_notrace
52 53
	EXPORT_SYMBOL(___preempt_schedule)
	EXPORT_SYMBOL(___preempt_schedule_notrace)
54 55
#endif

56 57 58
#if defined(CONFIG_TRACE_IRQFLAGS) \
 || defined(CONFIG_DEBUG_LOCK_ALLOC) \
 || defined(CONFIG_PREEMPT)
59
.L_restore:
60 61 62 63 64 65 66 67 68
	popq %r11
	popq %r10
	popq %r9
	popq %r8
	popq %rax
	popq %rcx
	popq %rdx
	popq %rsi
	popq %rdi
69
	popq %rbp
B
Borislav Petkov 已提交
70
	ret
71
	_ASM_NOKPROBE(.L_restore)
72
#endif