Path: blob/master/arch/x86/entry/vdso/vdso32/system_call.S
51764 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_STARTPROC1617/*18* If using int $0x80, there is no reason to muck about with the19* stack here. Unfortunately just overwriting the push instructions20* would mess up the CFI annotations, but it is only a 3-byte21* NOP in that case. This could be avoided by patching the22* vdso symbol table (not the code) and entry point, but that23* would a fair bit of tooling work or by simply compiling24* two different vDSO images, but that doesn't seem worth it.25*/26ALTERNATIVE "int $0x80; ret", "", X86_FEATURE_SYSFAST322728/*29* Reshuffle regs so that all of any of the entry instructions30* will preserve enough state.31*32* A really nice entry sequence would be:33* pushl %edx34* pushl %ecx35* movl %esp, %ecx36*37* Unfortunately, naughty Android versions between July and December38* 2015 actually hardcode the traditional Linux SYSENTER entry39* sequence. That is severely broken for a number of reasons (ask40* anyone with an AMD CPU, for example). Nonetheless, we try to keep41* it working approximately as well as it ever worked.42*43* This link may elucidate some of the history:44* https://android-review.googlesource.com/#/q/Iac3295376d61ef83e713ac9b528f3b50aa780cd745* personally, I find it hard to understand what's going on there.46*47* Note to future user developers: DO NOT USE SYSENTER IN YOUR CODE.48* Execute an indirect call to the address in the AT_SYSINFO auxv49* entry. That is the ONLY correct way to make a fast 32-bit system50* call on Linux. (Open-coding int $0x80 is also fine, but it's51* slow.)52*/53pushl %ecx54CFI_ADJUST_CFA_OFFSET 455CFI_REL_OFFSET ecx, 056pushl %edx57CFI_ADJUST_CFA_OFFSET 458CFI_REL_OFFSET edx, 059pushl %ebp60CFI_ADJUST_CFA_OFFSET 461CFI_REL_OFFSET ebp, 06263#define SYSENTER_SEQUENCE "movl %esp, %ebp; sysenter"64#define SYSCALL_SEQUENCE "movl %ecx, %ebp; syscall"6566ALTERNATIVE SYSENTER_SEQUENCE, SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL326768/* Re-enter using int $0x80 */69int $0x8070SYM_INNER_LABEL(int80_landing_pad, SYM_L_GLOBAL)7172/*73* Restore EDX and ECX in case they were clobbered. EBP is not74* clobbered (the kernel restores it), but it's cleaner and75* probably faster to pop it than to adjust ESP using addl.76*/77popl %ebp78CFI_RESTORE ebp79CFI_ADJUST_CFA_OFFSET -480popl %edx81CFI_RESTORE edx82CFI_ADJUST_CFA_OFFSET -483popl %ecx84CFI_RESTORE ecx85CFI_ADJUST_CFA_OFFSET -486RET87CFI_ENDPROC8889.size __kernel_vsyscall,.-__kernel_vsyscall90.previous919293