Skip to content

Commit af52201

Browse files
Dominik BrodowskiIngo Molnar
authored andcommitted
x86/entry: Do not special-case clone(2) in compat entry
With the CPU renaming registers on its own, and all the overhead of the syscall entry/exit, it is doubtful whether the compiled output of mov %r8, %rax mov %rcx, %r8 mov %rax, %rcx jmpq sys_clone is measurably slower than the hand-crafted version of xchg %r8, %rcx So get rid of this special case. Signed-off-by: Dominik Brodowski <[email protected]> Acked-by: Linus Torvalds <[email protected]> Acked-by: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 4ddb45d commit af52201

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

arch/x86/entry/entry_64_compat.S

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -406,15 +406,3 @@ ENTRY(entry_INT80_compat)
406406
TRACE_IRQS_ON
407407
jmp swapgs_restore_regs_and_return_to_usermode
408408
END(entry_INT80_compat)
409-
410-
ENTRY(stub32_clone)
411-
/*
412-
* The 32-bit clone ABI is: clone(..., int tls_val, int *child_tidptr).
413-
* The 64-bit clone ABI is: clone(..., int *child_tidptr, int tls_val).
414-
*
415-
* The native 64-bit kernel's sys_clone() implements the latter,
416-
* so we need to swap arguments here before calling it:
417-
*/
418-
xchg %r8, %rcx
419-
jmp sys_clone
420-
ENDPROC(stub32_clone)

arch/x86/entry/syscalls/syscall_32.tbl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
117 i386 ipc sys_ipc compat_sys_ipc
127127
118 i386 fsync sys_fsync
128128
119 i386 sigreturn sys_sigreturn sys32_sigreturn
129-
120 i386 clone sys_clone stub32_clone
129+
120 i386 clone sys_clone compat_sys_x86_clone
130130
121 i386 setdomainname sys_setdomainname
131131
122 i386 uname sys_newuname
132132
123 i386 modify_ldt sys_modify_ldt

arch/x86/ia32/sys_ia32.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,14 @@ COMPAT_SYSCALL_DEFINE6(x86_fallocate, int, fd, int, mode,
233233
return sys_fallocate(fd, mode, ((u64)offset_hi << 32) | offset_lo,
234234
((u64)len_hi << 32) | len_lo);
235235
}
236+
237+
/*
238+
* The 32-bit clone ABI is CONFIG_CLONE_BACKWARDS
239+
*/
240+
COMPAT_SYSCALL_DEFINE5(x86_clone, unsigned long, clone_flags,
241+
unsigned long, newsp, int __user *, parent_tidptr,
242+
unsigned long, tls_val, int __user *, child_tidptr)
243+
{
244+
return sys_clone(clone_flags, newsp, parent_tidptr, child_tidptr,
245+
tls_val);
246+
}

arch/x86/include/asm/sys_ia32.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ asmlinkage long compat_sys_x86_fadvise64(int, unsigned int, unsigned int,
5555
size_t, int);
5656
asmlinkage long compat_sys_x86_fallocate(int, int, unsigned int, unsigned int,
5757
unsigned int, unsigned int);
58+
asmlinkage long compat_sys_x86_clone(unsigned long, unsigned long, int __user *,
59+
unsigned long, int __user *);
5860

5961
/* ia32/ia32_signal.c */
6062
asmlinkage long sys32_sigreturn(void);

0 commit comments

Comments
 (0)