Path: blob/master/arch/x86/entry/vdso/vdso32/system_call.S
26516 views
/* SPDX-License-Identifier: GPL-2.0 */1/*2* AT_SYSINFO entry point3*/45#include <linux/linkage.h>6#include <asm/dwarf2.h>7#include <asm/cpufeatures.h>8#include <asm/alternative.h>910.text11.globl __kernel_vsyscall12.type __kernel_vsyscall,@function13ALIGN14__kernel_vsyscall:15CFI_STARTPROC16/*17* Reshuffle regs so that all of any of the entry instructions18* will preserve enough state.19*20* A really nice entry sequence would be:21* pushl %edx22* pushl %ecx23* movl %esp, %ecx24*25* Unfortunately, naughty Android versions between July and December26* 2015 actually hardcode the traditional Linux SYSENTER entry27* sequence. That is severely broken for a number of reasons (ask28* anyone with an AMD CPU, for example). Nonetheless, we try to keep29* it working approximately as well as it ever worked.30*31* This link may elucidate some of the history:32* https://android-review.googlesource.com/#/q/Iac3295376d61ef83e713ac9b528f3b50aa780cd733* personally, I find it hard to understand what's going on there.34*35* Note to future user developers: DO NOT USE SYSENTER IN YOUR CODE.36* Execute an indirect call to the address in the AT_SYSINFO auxv37* entry. That is the ONLY correct way to make a fast 32-bit system38* call on Linux. (Open-coding int $0x80 is also fine, but it's39* slow.)40*/41pushl %ecx42CFI_ADJUST_CFA_OFFSET 443CFI_REL_OFFSET ecx, 044pushl %edx45CFI_ADJUST_CFA_OFFSET 446CFI_REL_OFFSET edx, 047pushl %ebp48CFI_ADJUST_CFA_OFFSET 449CFI_REL_OFFSET ebp, 05051#define SYSENTER_SEQUENCE "movl %esp, %ebp; sysenter"52#define SYSCALL_SEQUENCE "movl %ecx, %ebp; syscall"5354#ifdef CONFIG_X86_6455/* If SYSENTER (Intel) or SYSCALL32 (AMD) is available, use it. */56ALTERNATIVE_2 "", SYSENTER_SEQUENCE, X86_FEATURE_SYSENTER32, \57SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL3258#else59ALTERNATIVE "", SYSENTER_SEQUENCE, X86_FEATURE_SEP60#endif6162/* Enter using int $0x80 */63int $0x8064SYM_INNER_LABEL(int80_landing_pad, SYM_L_GLOBAL)6566/*67* Restore EDX and ECX in case they were clobbered. EBP is not68* clobbered (the kernel restores it), but it's cleaner and69* probably faster to pop it than to adjust ESP using addl.70*/71popl %ebp72CFI_RESTORE ebp73CFI_ADJUST_CFA_OFFSET -474popl %edx75CFI_RESTORE edx76CFI_ADJUST_CFA_OFFSET -477popl %ecx78CFI_RESTORE ecx79CFI_ADJUST_CFA_OFFSET -480RET81CFI_ENDPROC8283.size __kernel_vsyscall,.-__kernel_vsyscall84.previous858687