1 /* SPDX-License-Identifier: GPL-2.0 */
3 * AT_SYSINFO entry point
6 #include <linux/linkage.h>
7 #include <asm/dwarf2.h>
8 #include <asm/cpufeatures.h>
9 #include <asm/alternative.h>
12 .globl __kernel_vsyscall
13 .type __kernel_vsyscall,@function
18 * Reshuffle regs so that all of any of the entry instructions
19 * will preserve enough state.
21 * A really nice entry sequence would be:
26 * Unfortunately, naughty Android versions between July and December
27 * 2015 actually hardcode the traditional Linux SYSENTER entry
28 * sequence. That is severely broken for a number of reasons (ask
29 * anyone with an AMD CPU, for example). Nonetheless, we try to keep
30 * it working approximately as well as it ever worked.
32 * This link may elucidate some of the history:
33 * https://android-review.googlesource.com/#/q/Iac3295376d61ef83e713ac9b528f3b50aa780cd7
34 * personally, I find it hard to understand what's going on there.
36 * Note to future user developers: DO NOT USE SYSENTER IN YOUR CODE.
37 * Execute an indirect call to the address in the AT_SYSINFO auxv
38 * entry. That is the ONLY correct way to make a fast 32-bit system
39 * call on Linux. (Open-coding int $0x80 is also fine, but it's
43 CFI_ADJUST_CFA_OFFSET 4
46 CFI_ADJUST_CFA_OFFSET 4
49 CFI_ADJUST_CFA_OFFSET 4
52 #define SYSENTER_SEQUENCE "movl %esp, %ebp; sysenter"
53 #define SYSCALL_SEQUENCE "movl %ecx, %ebp; syscall"
56 /* If SYSENTER (Intel) or SYSCALL32 (AMD) is available, use it. */
57 ALTERNATIVE_2 "", SYSENTER_SEQUENCE, X86_FEATURE_SYSENTER32, \
58 SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32
60 ALTERNATIVE "", SYSENTER_SEQUENCE, X86_FEATURE_SEP
63 /* Enter using int $0x80 */
65 SYM_INNER_LABEL(int80_landing_pad, SYM_L_GLOBAL)
68 * Restore EDX and ECX in case they were clobbered. EBP is not
69 * clobbered (the kernel restores it), but it's cleaner and
70 * probably faster to pop it than to adjust ESP using addl.
74 CFI_ADJUST_CFA_OFFSET -4
77 CFI_ADJUST_CFA_OFFSET -4
80 CFI_ADJUST_CFA_OFFSET -4
84 .size __kernel_vsyscall,.-__kernel_vsyscall