blob: 505b488fcc655b47945f0aeece64983736ae34c5 [file] [log] [blame]
Thomas Gleixner3f520cd22019-06-04 10:11:07 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Andi Kleencc1e6842006-09-26 10:52:29 +02002/*
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.
Andi Kleencc1e6842006-09-26 10:52:29 +02006 */
Borislav Petkov38e6b752011-05-31 22:21:54 +02007#include <linux/linkage.h>
Ingo Molnard36f9472015-06-03 18:29:26 +02008#include "calling.h"
Masami Hiramatsu98def1d2014-04-17 17:17:26 +09009#include <asm/asm.h>
Al Viro784d5692016-01-11 11:04:34 -050010#include <asm/export.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Borislav Petkov38e6b752011-05-31 22:21:54 +020012 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
Borislav Petkov0bab9cb2021-01-14 14:25:35 +010013 .macro THUNK name, func
Jiri Slaby76dc6d62019-10-11 13:50:44 +020014SYM_FUNC_START_NOALIGN(\name)
Josh Poimboeufd4bf7072016-05-17 13:06:06 -050015 pushq %rbp
16 movq %rsp, %rbp
Borislav Petkov38e6b752011-05-31 22:21:54 +020017
Ingo Molnar131484c2015-05-28 12:21:47 +020018 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
Borislav Petkov38e6b752011-05-31 22:21:54 +020027
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 call \func
Nick Desaulniers5e6dca82021-01-12 11:46:24 -080029 jmp __thunk_restore
Jiri Slaby76dc6d62019-10-11 13:50:44 +020030SYM_FUNC_END(\name)
Masami Hiramatsu98def1d2014-04-17 17:17:26 +090031 _ASM_NOKPROBE(\name)
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 .endm
33
Thomas Gleixner48593972019-07-26 23:19:42 +020034#ifdef CONFIG_PREEMPTION
Peter Zijlstra46db36a2020-03-20 12:56:39 +010035 THUNK preempt_schedule_thunk, preempt_schedule
36 THUNK preempt_schedule_notrace_thunk, preempt_schedule_notrace
37 EXPORT_SYMBOL(preempt_schedule_thunk)
38 EXPORT_SYMBOL(preempt_schedule_notrace_thunk)
Oleg Nesterov0ad6e3c2014-09-21 20:41:53 +020039#endif
40
Thomas Gleixner320100a2020-05-21 22:05:52 +020041#ifdef CONFIG_PREEMPTION
Nick Desaulniers5e6dca82021-01-12 11:46:24 -080042SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore)
Ingo Molnar131484c2015-05-28 12:21:47 +020043 popq %r11
44 popq %r10
45 popq %r9
46 popq %r8
47 popq %rax
48 popq %rcx
49 popq %rdx
50 popq %rsi
51 popq %rdi
Josh Poimboeufd4bf7072016-05-17 13:06:06 -050052 popq %rbp
Peter Zijlstraf94909c2021-12-04 14:43:40 +010053 RET
Nick Desaulniers5e6dca82021-01-12 11:46:24 -080054 _ASM_NOKPROBE(__thunk_restore)
55SYM_CODE_END(__thunk_restore)
Denys Vlasenko69e85442015-02-26 14:40:24 -080056#endif