xref: /openbmc/linux/arch/x86/entry/thunk_64.S (revision 7af6fbdd)
1/* SPDX-License-Identifier: GPL-2.0-only */
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.
6 */
7#include <linux/linkage.h>
8#include "calling.h"
9#include <asm/asm.h>
10#include <asm/export.h>
11
12	/* rdi:	arg1 ... normal C conventions. rax is saved/restored. */
13	.macro THUNK name, func, put_ret_addr_in_rdi=0
14SYM_FUNC_START_NOALIGN(\name)
15	pushq %rbp
16	movq %rsp, %rbp
17
18	pushq %rdi
19	pushq %rsi
20	pushq %rdx
21	pushq %rcx
22	pushq %rax
23	pushq %r8
24	pushq %r9
25	pushq %r10
26	pushq %r11
27
28	.if \put_ret_addr_in_rdi
29	/* 8(%rbp) is return addr on stack */
30	movq 8(%rbp), %rdi
31	.endif
32
33	call \func
34	jmp  .L_restore
35SYM_FUNC_END(\name)
36	_ASM_NOKPROBE(\name)
37	.endm
38
39#ifdef CONFIG_PREEMPTION
40	THUNK preempt_schedule_thunk, preempt_schedule
41	THUNK preempt_schedule_notrace_thunk, preempt_schedule_notrace
42	EXPORT_SYMBOL(preempt_schedule_thunk)
43	EXPORT_SYMBOL(preempt_schedule_notrace_thunk)
44#endif
45
46#ifdef CONFIG_PREEMPTION
47SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
48	popq %r11
49	popq %r10
50	popq %r9
51	popq %r8
52	popq %rax
53	popq %rcx
54	popq %rdx
55	popq %rsi
56	popq %rdi
57	popq %rbp
58	ret
59	_ASM_NOKPROBE(.L_restore)
60SYM_CODE_END(.L_restore)
61#endif
62