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
	.globl \name
16
	.type \name, @function
17
\name:
18 19
	pushq %rbp
	movq %rsp, %rbp
B
Borislav Petkov 已提交
20

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

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

36
	call \func
37
	jmp  .L_restore
38
	_ASM_NOKPROBE(\name)
39 40
	.endm

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

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

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

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