Skip to content

Commit 36d83c2

Browse files
H. Peter Anvinhansendc
authored andcommitted
x86/entry/vdso32: When using int $0x80, use it directly
When neither sysenter32 nor syscall32 is available (on either FRED-capable 64-bit hardware or old 32-bit hardware), there is no reason to do a bunch of stack shuffling in __kernel_vsyscall. Unfortunately, just overwriting the initial "push" instructions will mess up the CFI annotations, so suffer the 3-byte NOP if not applicable. Similarly, inline the int $0x80 when doing inline system calls in the vdso instead of calling __kernel_vsyscall. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Link: https://patch.msgid.link/20251216212606.1325678-11-hpa@zytor.com
1 parent f49ecf5 commit 36d83c2

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

arch/x86/entry/vdso/vdso32/system_call.S

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@
1414
ALIGN
1515
__kernel_vsyscall:
1616
CFI_STARTPROC
17+
18+
/*
19+
* If using int $0x80, there is no reason to muck about with the
20+
* stack here. Unfortunately just overwriting the push instructions
21+
* would mess up the CFI annotations, but it is only a 3-byte
22+
* NOP in that case. This could be avoided by patching the
23+
* vdso symbol table (not the code) and entry point, but that
24+
* would a fair bit of tooling work or by simply compiling
25+
* two different vDSO images, but that doesn't seem worth it.
26+
*/
27+
ALTERNATIVE "int $0x80; ret", "", X86_FEATURE_SYSFAST32
28+
1729
/*
1830
* Reshuffle regs so that all of any of the entry instructions
1931
* will preserve enough state.
@@ -52,11 +64,9 @@ __kernel_vsyscall:
5264
#define SYSENTER_SEQUENCE "movl %esp, %ebp; sysenter"
5365
#define SYSCALL_SEQUENCE "movl %ecx, %ebp; syscall"
5466

55-
/* If SYSENTER (Intel) or SYSCALL32 (AMD) is available, use it. */
56-
ALTERNATIVE_2 "", SYSENTER_SEQUENCE, X86_FEATURE_SYSFAST32, \
57-
SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32
67+
ALTERNATIVE SYSENTER_SEQUENCE, SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32
5868

59-
/* Enter using int $0x80 */
69+
/* Re-enter using int $0x80 */
6070
int $0x80
6171
SYM_INNER_LABEL(int80_landing_pad, SYM_L_GLOBAL)
6272

arch/x86/include/asm/vdso/sys_call.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
# define __sys_reg4 "r10"
2121
# define __sys_reg5 "r8"
2222
#else
23-
# define __sys_instr "call __kernel_vsyscall"
23+
# define __sys_instr ALTERNATIVE("ds;ds;ds;int $0x80", \
24+
"call __kernel_vsyscall", \
25+
X86_FEATURE_SYSFAST32)
2426
# define __sys_clobber "memory"
2527
# define __sys_nr(x,y) __NR_ ## x ## y
2628
# define __sys_reg1 "ebx"

0 commit comments

Comments
 (0)