Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/asm/entry: Untangle 'system_call' into two entry points: entry_SYSCALL_64 and entry_INT80_32

The 'system_call' entry points differ starkly between native 32-bit and 64-bit
kernels: on 32-bit kernels it defines the INT 0x80 entry point, while on
64-bit it's the SYSCALL entry point.

This is pretty confusing when looking at generic code, and it also obscures
the nature of the entry point at the assembly level.

So unangle this by splitting the name into its two uses:

system_call (32) -> entry_INT80_32
system_call (64) -> entry_SYSCALL_64

As per the generic naming scheme for x86 system call entry points:

entry_MNEMONIC_qualifier

where 'qualifier' is one of _32, _64 or _compat.

Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

+14 -14
+2 -2
arch/x86/entry/entry_32.S
··· 415 415 ENDPROC(entry_SYSENTER_32) 416 416 417 417 # system call handler stub 418 - ENTRY(system_call) 418 + ENTRY(entry_INT80_32) 419 419 ASM_CLAC 420 420 pushl %eax # save orig_eax 421 421 SAVE_ALL ··· 508 508 lss (%esp), %esp /* switch to espfix segment */ 509 509 jmp restore_nocheck 510 510 #endif 511 - ENDPROC(system_call) 511 + ENDPROC(entry_INT80_32) 512 512 513 513 # perform work that needs to be done immediately before resumption 514 514 ALIGN
+5 -5
arch/x86/entry/entry_64.S
··· 137 137 * with them due to bugs in both AMD and Intel CPUs. 138 138 */ 139 139 140 - ENTRY(system_call) 140 + ENTRY(entry_SYSCALL_64) 141 141 /* 142 142 * Interrupts are off on entry. 143 143 * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON, ··· 149 149 * after the swapgs, so that it can do the swapgs 150 150 * for the guest and jump here on syscall. 151 151 */ 152 - GLOBAL(system_call_after_swapgs) 152 + GLOBAL(entry_SYSCALL_64_after_swapgs) 153 153 154 154 movq %rsp,PER_CPU_VAR(rsp_scratch) 155 155 movq PER_CPU_VAR(cpu_current_top_of_stack),%rsp ··· 182 182 183 183 testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS) 184 184 jnz tracesys 185 - system_call_fastpath: 185 + entry_SYSCALL_64_fastpath: 186 186 #if __SYSCALL_MASK == ~0 187 187 cmpq $__NR_syscall_max,%rax 188 188 #else ··· 246 246 jnz tracesys_phase2 /* if needed, run the slow path */ 247 247 RESTORE_C_REGS_EXCEPT_RAX /* else restore clobbered regs */ 248 248 movq ORIG_RAX(%rsp), %rax 249 - jmp system_call_fastpath /* and return to the fast path */ 249 + jmp entry_SYSCALL_64_fastpath /* and return to the fast path */ 250 250 251 251 tracesys_phase2: 252 252 SAVE_EXTRA_REGS ··· 411 411 opportunistic_sysret_failed: 412 412 SWAPGS 413 413 jmp restore_c_regs_and_iret 414 - END(system_call) 414 + END(entry_SYSCALL_64) 415 415 416 416 417 417 .macro FORK_LIKE func
+3 -2
arch/x86/include/asm/proto.h
··· 5 5 6 6 /* misc architecture specific prototypes */ 7 7 8 - void system_call(void); 9 8 void syscall_init(void); 10 9 11 - void entry_INT80_compat(void); 10 + void entry_SYSCALL_64(void); 12 11 void entry_SYSCALL_compat(void); 12 + void entry_INT80_32(void); 13 + void entry_INT80_compat(void); 13 14 void entry_SYSENTER_32(void); 14 15 void entry_SYSENTER_compat(void); 15 16
+1 -1
arch/x86/kernel/cpu/common.c
··· 1204 1204 * set CS/DS but only a 32bit target. LSTAR sets the 64bit rip. 1205 1205 */ 1206 1206 wrmsrl(MSR_STAR, ((u64)__USER32_CS)<<48 | ((u64)__KERNEL_CS)<<32); 1207 - wrmsrl(MSR_LSTAR, system_call); 1207 + wrmsrl(MSR_LSTAR, entry_SYSCALL_64); 1208 1208 1209 1209 #ifdef CONFIG_IA32_EMULATION 1210 1210 wrmsrl(MSR_CSTAR, entry_SYSCALL_compat);
+2 -3
arch/x86/kernel/traps.c
··· 72 72 #else 73 73 #include <asm/processor-flags.h> 74 74 #include <asm/setup.h> 75 - 76 - asmlinkage int system_call(void); 75 + #include <asm/proto.h> 77 76 #endif 78 77 79 78 /* Must be page-aligned because the real IDT is used in a fixmap. */ ··· 996 997 #endif 997 998 998 999 #ifdef CONFIG_X86_32 999 - set_system_trap_gate(IA32_SYSCALL_VECTOR, &system_call); 1000 + set_system_trap_gate(IA32_SYSCALL_VECTOR, entry_INT80_32); 1000 1001 set_bit(IA32_SYSCALL_VECTOR, used_vectors); 1001 1002 #endif 1002 1003
+1 -1
arch/x86/xen/xen-asm_64.S
··· 114 114 /* Normal 64-bit system call target */ 115 115 ENTRY(xen_syscall_target) 116 116 undo_xen_syscall 117 - jmp system_call_after_swapgs 117 + jmp entry_SYSCALL_64_after_swapgs 118 118 ENDPROC(xen_syscall_target) 119 119 120 120 #ifdef CONFIG_IA32_EMULATION