thunk_64.S 1.5 KB
Newer Older
1 2 3 4
/*
 * 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.
5
 * Added trace_hardirqs callers - Copyright 2007 Steven Rostedt, Red Hat, Inc.
6 7
 * Subject to the GNU public license, v.2. No warranty of any kind.
 */
B
Borislav Petkov 已提交
8
#include <linux/linkage.h>
9
#include "calling.h"
10
#include <asm/asm.h>
L
Linus Torvalds 已提交
11

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

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

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

35
	call \func
36
	jmp  .L_restore
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
#endif

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