Thomas Gleixner | 3f520cd2 | 2019-06-04 10:11:07 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Andi Kleen | cc1e684 | 2006-09-26 10:52:29 +0200 | [diff] [blame] | 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. |
Andi Kleen | cc1e684 | 2006-09-26 10:52:29 +0200 | [diff] [blame] | 6 | */ |
Borislav Petkov | 38e6b75 | 2011-05-31 22:21:54 +0200 | [diff] [blame] | 7 | #include <linux/linkage.h> |
Ingo Molnar | d36f947 | 2015-06-03 18:29:26 +0200 | [diff] [blame] | 8 | #include "calling.h" |
Masami Hiramatsu | 98def1d | 2014-04-17 17:17:26 +0900 | [diff] [blame] | 9 | #include <asm/asm.h> |
Al Viro | 784d569 | 2016-01-11 11:04:34 -0500 | [diff] [blame] | 10 | #include <asm/export.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Borislav Petkov | 38e6b75 | 2011-05-31 22:21:54 +0200 | [diff] [blame] | 12 | /* rdi: arg1 ... normal C conventions. rax is saved/restored. */ |
Borislav Petkov | 0bab9cb | 2021-01-14 14:25:35 +0100 | [diff] [blame] | 13 | .macro THUNK name, func |
Jiri Slaby | 76dc6d6 | 2019-10-11 13:50:44 +0200 | [diff] [blame] | 14 | SYM_FUNC_START_NOALIGN(\name) |
Josh Poimboeuf | d4bf707 | 2016-05-17 13:06:06 -0500 | [diff] [blame] | 15 | pushq %rbp |
| 16 | movq %rsp, %rbp |
Borislav Petkov | 38e6b75 | 2011-05-31 22:21:54 +0200 | [diff] [blame] | 17 | |
Ingo Molnar | 131484c | 2015-05-28 12:21:47 +0200 | [diff] [blame] | 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 |
Borislav Petkov | 38e6b75 | 2011-05-31 22:21:54 +0200 | [diff] [blame] | 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | call \func |
Nick Desaulniers | 5e6dca8 | 2021-01-12 11:46:24 -0800 | [diff] [blame] | 29 | jmp __thunk_restore |
Jiri Slaby | 76dc6d6 | 2019-10-11 13:50:44 +0200 | [diff] [blame] | 30 | SYM_FUNC_END(\name) |
Masami Hiramatsu | 98def1d | 2014-04-17 17:17:26 +0900 | [diff] [blame] | 31 | _ASM_NOKPROBE(\name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | .endm |
| 33 | |
Thomas Gleixner | 4859397 | 2019-07-26 23:19:42 +0200 | [diff] [blame] | 34 | #ifdef CONFIG_PREEMPTION |
Peter Zijlstra | 46db36a | 2020-03-20 12:56:39 +0100 | [diff] [blame] | 35 | 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 Nesterov | 0ad6e3c | 2014-09-21 20:41:53 +0200 | [diff] [blame] | 39 | #endif |
| 40 | |
Thomas Gleixner | 320100a | 2020-05-21 22:05:52 +0200 | [diff] [blame] | 41 | #ifdef CONFIG_PREEMPTION |
Nick Desaulniers | 5e6dca8 | 2021-01-12 11:46:24 -0800 | [diff] [blame] | 42 | SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore) |
Ingo Molnar | 131484c | 2015-05-28 12:21:47 +0200 | [diff] [blame] | 43 | 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 Poimboeuf | d4bf707 | 2016-05-17 13:06:06 -0500 | [diff] [blame] | 52 | popq %rbp |
Borislav Petkov | 38e6b75 | 2011-05-31 22:21:54 +0200 | [diff] [blame] | 53 | ret |
Nick Desaulniers | 5e6dca8 | 2021-01-12 11:46:24 -0800 | [diff] [blame] | 54 | _ASM_NOKPROBE(__thunk_restore) |
| 55 | SYM_CODE_END(__thunk_restore) |
Denys Vlasenko | 69e8544 | 2015-02-26 14:40:24 -0800 | [diff] [blame] | 56 | #endif |