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 15
	.globl \name
\name:
B
Borislav Petkov 已提交
16 17

	/* this one pushes 9 elems, the next one would be %rIP */
18 19 20 21 22 23 24 25 26
	pushq %rdi
	pushq %rsi
	pushq %rdx
	pushq %rcx
	pushq %rax
	pushq %r8
	pushq %r9
	pushq %r10
	pushq %r11
B
Borislav Petkov 已提交
27 28

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

33 34
	call \func
	jmp  restore
35
	_ASM_NOKPROBE(\name)
36 37
	.endm

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

#ifdef CONFIG_DEBUG_LOCK_ALLOC
B
Borislav Petkov 已提交
44
	THUNK lockdep_sys_exit_thunk,lockdep_sys_exit
45
#endif
B
Borislav Petkov 已提交
46

47 48 49 50 51 52 53
#ifdef CONFIG_PREEMPT
	THUNK ___preempt_schedule, preempt_schedule
#ifdef CONFIG_CONTEXT_TRACKING
	THUNK ___preempt_schedule_context, preempt_schedule_context
#endif
#endif

54 55 56
#if defined(CONFIG_TRACE_IRQFLAGS) \
 || defined(CONFIG_DEBUG_LOCK_ALLOC) \
 || defined(CONFIG_PREEMPT)
L
Linus Torvalds 已提交
57
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
B
Borislav Petkov 已提交
67
	ret
68
	_ASM_NOKPROBE(restore)
69
#endif