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

x86/entry/64: Migrate 64-bit and compat syscalls to the new exit handlers and remove old assembly code

These need to be migrated together, as the compat case used to
jump into the middle of the 64-bit exit code.

Remove the old assembly code.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
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: Denys Vlasenko <vda.linux@googlemail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: paulmck@linux.vnet.ibm.com
Link: http://lkml.kernel.org/r/d4d1d70de08ac3640badf50048a9e8f18fe2497f.1435952415.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Andy Lutomirski and committed by
Ingo Molnar
29ea1b25 cb6f64ed

+11 -64
+8 -61
arch/x86/entry/entry_64.S
··· 229 229 */ 230 230 USERGS_SYSRET64 231 231 232 + GLOBAL(int_ret_from_sys_call_irqs_off) 233 + TRACE_IRQS_ON 234 + ENABLE_INTERRUPTS(CLBR_NONE) 235 + jmp int_ret_from_sys_call 236 + 232 237 /* Do syscall entry tracing */ 233 238 tracesys: 234 239 movq %rsp, %rdi ··· 277 272 * Has correct iret frame. 278 273 */ 279 274 GLOBAL(int_ret_from_sys_call) 280 - DISABLE_INTERRUPTS(CLBR_NONE) 281 - int_ret_from_sys_call_irqs_off: /* jumps come here from the irqs-off SYSRET path */ 282 - TRACE_IRQS_OFF 283 - movl $_TIF_ALLWORK_MASK, %edi 284 - /* edi: mask to check */ 285 - GLOBAL(int_with_check) 286 - LOCKDEP_SYS_EXIT_IRQ 287 - GET_THREAD_INFO(%rcx) 288 - movl TI_flags(%rcx), %edx 289 - andl %edi, %edx 290 - jnz int_careful 291 - andl $~TS_COMPAT, TI_status(%rcx) 292 - jmp syscall_return 293 - 294 - /* 295 - * Either reschedule or signal or syscall exit tracking needed. 296 - * First do a reschedule test. 297 - * edx: work, edi: workmask 298 - */ 299 - int_careful: 300 - bt $TIF_NEED_RESCHED, %edx 301 - jnc int_very_careful 302 - TRACE_IRQS_ON 303 - ENABLE_INTERRUPTS(CLBR_NONE) 304 - pushq %rdi 305 - SCHEDULE_USER 306 - popq %rdi 307 - DISABLE_INTERRUPTS(CLBR_NONE) 308 - TRACE_IRQS_OFF 309 - jmp int_with_check 310 - 311 - /* handle signals and tracing -- both require a full pt_regs */ 312 - int_very_careful: 313 - TRACE_IRQS_ON 314 - ENABLE_INTERRUPTS(CLBR_NONE) 315 275 SAVE_EXTRA_REGS 316 - /* Check for syscall exit trace */ 317 - testl $_TIF_WORK_SYSCALL_EXIT, %edx 318 - jz int_signal 319 - pushq %rdi 320 - leaq 8(%rsp), %rdi /* &ptregs -> arg1 */ 321 - call syscall_trace_leave 322 - popq %rdi 323 - andl $~(_TIF_WORK_SYSCALL_EXIT|_TIF_SYSCALL_EMU), %edi 324 - jmp int_restore_rest 325 - 326 - int_signal: 327 - testl $_TIF_DO_NOTIFY_MASK, %edx 328 - jz 1f 329 - movq %rsp, %rdi /* &ptregs -> arg1 */ 330 - xorl %esi, %esi /* oldset -> arg2 */ 331 - call do_notify_resume 332 - 1: movl $_TIF_WORK_MASK, %edi 333 - int_restore_rest: 276 + movq %rsp, %rdi 277 + call syscall_return_slowpath /* returns with IRQs disabled */ 334 278 RESTORE_EXTRA_REGS 335 - DISABLE_INTERRUPTS(CLBR_NONE) 336 - TRACE_IRQS_OFF 337 - jmp int_with_check 338 - 339 - syscall_return: 340 - /* The IRETQ could re-enable interrupts: */ 341 - DISABLE_INTERRUPTS(CLBR_ANY) 342 - TRACE_IRQS_IRETQ 279 + TRACE_IRQS_IRETQ /* we're about to change IF */ 343 280 344 281 /* 345 282 * Try to use SYSRET instead of IRET if we're returning to
+3 -3
arch/x86/entry/entry_64_compat.S
··· 210 210 .endm 211 211 212 212 .macro auditsys_exit exit 213 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS) 214 - jnz ia32_ret_from_sys_call 215 213 TRACE_IRQS_ON 216 214 ENABLE_INTERRUPTS(CLBR_NONE) 215 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS) 216 + jnz ia32_ret_from_sys_call 217 217 movl %eax, %esi /* second arg, syscall return value */ 218 218 cmpl $-MAX_ERRNO, %eax /* is it an error ? */ 219 219 jbe 1f ··· 232 232 movq %rax, R10(%rsp) 233 233 movq %rax, R9(%rsp) 234 234 movq %rax, R8(%rsp) 235 - jmp int_with_check 235 + jmp int_ret_from_sys_call_irqs_off 236 236 .endm 237 237 238 238 sysenter_auditsys: