From: Denys Vlasenko <dvlasenk@redhat.com>
To: Andy Lutomirski <luto@kernel.org>,
x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Brian Gerst <brgerst@gmail.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Borislav Petkov <bp@alien8.de>
Subject: Re: [PATCH v2 27/36] x86/entry/32: Re-implement SYSENTER using the new C path
Date: Wed, 07 Oct 2015 20:08:26 +0200 [thread overview]
Message-ID: <56155F9A.2070209@redhat.com> (raw)
In-Reply-To: <5b99659e8be70f3dd10cd8970a5c90293d9ad9a7.1444091585.git.luto@kernel.org>
On 10/06/2015 02:48 AM, Andy Lutomirski wrote:
> # SYSENTER call handler stub
> ENTRY(entry_SYSENTER_32)
> movl TSS_sysenter_sp0(%esp), %esp
> sysenter_past_esp:
> + pushl $__USER_DS /* pt_regs->ss */
> + pushl %ecx /* pt_regs->cx */
> + pushfl /* pt_regs->flags (except IF = 0) */
> + orl $X86_EFLAGS_IF, (%esp) /* Fix IF */
> + pushl $__USER_CS /* pt_regs->cs */
> + pushl $0 /* pt_regs->ip = 0 (placeholder) */
> + pushl %eax /* pt_regs->orig_ax */
> + SAVE_ALL pt_regs_ax=$-ENOSYS /* save rest */
> +
> /*
> - * Interrupts are disabled here, but we can't trace it until
> - * enough kernel state to call TRACE_IRQS_OFF can be called - but
> - * we immediately enable interrupts at that point anyway.
> - */
> - pushl $__USER_DS
> - pushl %ebp
> - pushfl
> - orl $X86_EFLAGS_IF, (%esp)
> - pushl $__USER_CS
> - /*
> - * Push current_thread_info()->sysenter_return to the stack.
> - * A tiny bit of offset fixup is necessary: TI_sysenter_return
> - * is relative to thread_info, which is at the bottom of the
> - * kernel stack page. 4*4 means the 4 words pushed above;
> - * TOP_OF_KERNEL_STACK_PADDING takes us to the top of the stack;
> - * and THREAD_SIZE takes us to the bottom.
> + * User mode is traced as though IRQs are on, and SYSENTER
> + * turned them off.
> */
> - pushl ((TI_sysenter_return) - THREAD_SIZE + TOP_OF_KERNEL_STACK_PADDING + 4*4)(%esp)
> -
> - pushl %eax
> - SAVE_ALL
> - ENABLE_INTERRUPTS(CLBR_NONE)
> -
> -/*
> - * Load the potential sixth argument from user stack.
> - * Careful about security.
> - */
> - cmpl $__PAGE_OFFSET-3, %ebp
> - jae syscall_fault
> - ASM_STAC
> -1: movl (%ebp), %ebp
> - ASM_CLAC
> - movl %ebp, PT_EBP(%esp)
> - _ASM_EXTABLE(1b, syscall_fault)
> -
> - GET_THREAD_INFO(%ebp)
> -
> - testl $_TIF_WORK_SYSCALL_ENTRY, TI_flags(%ebp)
> - jnz syscall_trace_entry
> -sysenter_do_call:
> - cmpl $(NR_syscalls), %eax
> - jae sysenter_badsys
> - call *sys_call_table(, %eax, 4)
> -sysenter_after_call:
> - movl %eax, PT_EAX(%esp)
> - LOCKDEP_SYS_EXIT
> - DISABLE_INTERRUPTS(CLBR_ANY)
> TRACE_IRQS_OFF
> - movl TI_flags(%ebp), %ecx
> - testl $_TIF_ALLWORK_MASK, %ecx
> - jnz syscall_exit_work_irqs_off
> -sysenter_exit:
> -/* if something modifies registers it must also disable sysexit */
> - movl PT_EIP(%esp), %edx
> - movl PT_OLDESP(%esp), %ecx
> - xorl %ebp, %ebp
> - TRACE_IRQS_ON
> +
> + movl %esp, %eax
> + call do_fast_syscall_32
> + testl %eax, %eax
> + jz .Lsyscall_32_done
> +
> +/* Opportunistic SYSEXIT */
> + TRACE_IRQS_ON /* User mode traces as IRQs on. */
> + movl PT_EIP(%esp), %edx /* pt_regs->ip */
> + movl PT_OLDESP(%esp), %ecx /* pt_regs->sp */
> + popl %ebx /* pt_regs->bx */
> + addl $2*4, %esp /* skip pt_regs->cx and pt_regs->dx */
Here stack engine and ALUs operating on ESP conflict,
potentially adding a stall both before and after ADD.
It might be faster to just pop twice into an unused register, say,
popl %eax
popl %eax
> + popl %esi /* pt_regs->si */
> + popl %edi /* pt_regs->di */
> + popl %ebp /* pt_regs->bp */
> + popl %eax /* pt_regs->ax */
> 1: mov PT_FS(%esp), %fs
> PTGS_TO_GS
next prev parent reply other threads:[~2015-10-07 18:08 UTC|newest]
Thread overview: 124+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-06 0:47 [PATCH v2 00/36] x86: Rewrite all syscall entries except native 64-bit Andy Lutomirski
2015-10-06 0:47 ` [PATCH v2 01/36] x86/uaccess: Tell the compiler that uaccess is unlikely to fault Andy Lutomirski
2015-10-07 16:15 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:47 ` [PATCH v2 02/36] x86/uaccess: __chk_range_not_ok is unlikely to return true Andy Lutomirski
2015-10-07 10:59 ` Borislav Petkov
2015-10-07 16:23 ` Ingo Molnar
2015-10-07 16:16 ` [tip:x86/asm] x86/uaccess: Add unlikely() to __chk_range_not_ok() failure paths tip-bot for Andy Lutomirski
2015-10-06 0:47 ` [PATCH v2 03/36] selftests/x86: Add a test for vDSO unwinding Andy Lutomirski
2015-10-07 16:16 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:47 ` [PATCH v2 04/36] selftests/x86: Add a test for syscall restart and arg modification Andy Lutomirski
2015-10-07 16:17 ` [tip:x86/asm] selftests/x86: Add a test for ptrace " tip-bot for Andy Lutomirski
2015-10-06 0:47 ` [PATCH v2 05/36] x86/entry/64/compat: Fix SYSENTER's NT flag before user memory access Andy Lutomirski
2015-10-07 11:10 ` Borislav Petkov
2015-10-07 14:33 ` Brian Gerst
2015-10-07 15:05 ` Borislav Petkov
2015-10-09 17:08 ` [PATCH] x86/entry/64/compat: Document sysenter_fix_flags's reason for existence Borislav Petkov
2015-10-09 19:06 ` Andy Lutomirski
2015-10-11 9:09 ` [tip:x86/asm] x86/entry/64/compat: Document sysenter_fix_flags' s " tip-bot for Borislav Petkov
2015-10-07 16:17 ` [tip:x86/asm] x86/entry/64/compat: Fix SYSENTER' s NT flag before user memory access tip-bot for Andy Lutomirski
2015-10-06 0:47 ` [PATCH v2 06/36] x86/entry: Move lockdep_sys_exit to prepare_exit_to_usermode Andy Lutomirski
2015-10-07 16:17 ` [tip:x86/asm] x86/entry, locking/lockdep: Move lockdep_sys_exit() to prepare_exit_to_usermode() tip-bot for Andy Lutomirski
2015-10-08 8:59 ` Peter Zijlstra
2015-10-09 19:34 ` Andy Lutomirski
2015-10-06 0:47 ` [PATCH v2 07/36] x86/entry/64/compat: After SYSENTER, move STI after the NT fixup Andy Lutomirski
2015-10-07 16:18 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-07 17:39 ` [PATCH v2 07/36] " Denys Vlasenko
2015-10-07 19:02 ` Andy Lutomirski
2015-10-09 19:48 ` Andy Lutomirski
2015-10-12 17:48 ` Denys Vlasenko
2015-10-12 18:11 ` Brian Gerst
2015-10-06 0:47 ` [PATCH v2 08/36] x86/vdso: Remove runtime 32-bit vDSO selection Andy Lutomirski
2015-10-07 16:18 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-07 17:00 ` Brian Gerst
2015-10-06 0:47 ` [PATCH v2 09/36] x86/asm: Re-add manual CFI infrastructure Andy Lutomirski
2015-10-06 8:23 ` Ingo Molnar
2015-10-06 18:21 ` Andy Lutomirski
2015-10-08 13:11 ` Borislav Petkov
2015-10-08 14:14 ` Ingo Molnar
2015-10-09 13:06 ` [tip:x86/asm] x86/asm: Re-add parts of the " tip-bot for Andy Lutomirski
2015-10-06 0:47 ` [PATCH v2 10/36] x86/vdso: Define BUILD_VDSO while building and emit .eh_frame in asm Andy Lutomirski
2015-10-09 7:21 ` Ingo Molnar
2015-10-09 13:07 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:47 ` [PATCH v2 11/36] x86/vdso: Replace hex int80 CFI annotations with gas directives Andy Lutomirski
2015-10-09 13:07 ` [tip:x86/asm] x86/vdso: Replace hex int80 CFI annotations with GAS directives tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 12/36] x86/elf/64: Clear more registers in elf_common_init Andy Lutomirski
2015-10-09 13:08 ` [tip:x86/asm] x86/elf/64: Clear more registers in elf_common_init () tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 13/36] x86/vdso/32: Save extra registers in the INT80 vsyscall path Andy Lutomirski
2015-10-09 13:08 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 14/36] x86/entry/64/compat: Disable SYSENTER and SYSCALL32 entries Andy Lutomirski
2015-10-08 15:41 ` Borislav Petkov
2015-10-09 19:11 ` Andy Lutomirski
2015-10-09 13:08 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 15/36] x86/entry/64/compat: Remove audit optimizations Andy Lutomirski
2015-10-09 13:09 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 16/36] x86/entry/64/compat: Remove most of the fast system call machinery Andy Lutomirski
2015-10-09 13:09 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 17/36] x86/entry/64/compat: Set up full pt_regs for all compat syscalls Andy Lutomirski
2015-10-09 13:09 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 18/36] x86/entry/syscalls: Move syscall table declarations into asm/syscalls.h Andy Lutomirski
2015-10-09 13:10 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 19/36] x86/syscalls: Give sys_call_ptr_t a useful type Andy Lutomirski
2015-10-09 13:10 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 20/36] x86/entry: Add do_syscall_32, a C function to do 32-bit syscalls Andy Lutomirski
2015-10-09 13:10 ` [tip:x86/asm] x86/entry: Add do_syscall_32(), " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 21/36] x86/entry/64/compat: Migrate the body of the syscall entry to C Andy Lutomirski
2015-10-09 13:11 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 22/36] x86/entry: Add C code for fast system call entries Andy Lutomirski
2015-10-06 8:25 ` Linus Torvalds
2015-10-06 8:29 ` Linus Torvalds
2015-10-06 18:25 ` Andy Lutomirski
2015-10-09 13:11 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 23/36] x86/vdso/compat: Wire up SYSENTER and SYSCSALL for compat userspace Andy Lutomirski
2015-10-09 13:11 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 24/36] x86/entry/compat: Implement opportunistic SYSRETL for compat syscalls Andy Lutomirski
2015-10-09 13:12 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-12 16:15 ` [PATCH v2 24/36] " Borislav Petkov
2015-10-14 16:25 ` Andy Lutomirski
2015-10-14 16:31 ` Borislav Petkov
2015-10-06 0:48 ` [PATCH v2 25/36] x86/entry/32: Open-code return tracking from fork and kthreads Andy Lutomirski
2015-10-09 13:12 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 26/36] x86/entry/32: Switch INT80 to the new C syscall path Andy Lutomirski
2015-10-09 13:12 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-15 18:09 ` Borislav Petkov
2015-10-15 19:09 ` Andy Lutomirski
2015-10-16 10:52 ` Borislav Petkov
[not found] ` <20151016140502.GG31612@pd.tnic>
2015-10-16 15:57 ` Andy Lutomirski
2015-10-16 17:14 ` Borislav Petkov
2015-10-16 15:59 ` Andy Lutomirski
2015-10-16 17:34 ` Borislav Petkov
2015-10-16 18:22 ` Brian Gerst
2015-10-16 18:32 ` Andy Lutomirski
2015-10-16 19:36 ` Brian Gerst
2015-10-06 0:48 ` [PATCH v2 27/36] x86/entry/32: Re-implement SYSENTER using the new C path Andy Lutomirski
2015-10-07 18:08 ` Denys Vlasenko [this message]
2015-10-07 19:06 ` Andy Lutomirski
2015-10-09 13:13 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 28/36] x86/asm: Remove thread_info.sysenter_return Andy Lutomirski
2015-10-09 13:13 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 29/36] x86/entry: Remove unnecessary IRQ twiddling in fast 32-bit syscalls Andy Lutomirski
2015-10-09 13:13 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 30/36] x86/entry: Make irqs_disabled checks in exit code depend on lockdep Andy Lutomirski
2015-10-09 13:14 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 31/36] x86/entry: Force inlining of 32-bit syscall code Andy Lutomirski
2015-10-09 13:14 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 32/36] x86/entry: Micro-optimize compat fast syscall arg fetch Andy Lutomirski
2015-10-09 7:32 ` Ingo Molnar
2015-10-09 19:28 ` Andy Lutomirski
2015-10-10 9:05 ` Ingo Molnar
2015-10-09 13:14 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 33/36] x86/entry: Hide two syscall entry assertions behind CONFIG_DEBUG_ENTRY Andy Lutomirski
2015-10-09 13:15 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 34/36] x86/entry: Use pt_regs_to_thread_info() in syscall entry tracing Andy Lutomirski
2015-10-09 13:15 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 35/36] x86/entry: Split and inline prepare_exit_to_usermode Andy Lutomirski
2015-10-09 13:15 ` [tip:x86/asm] x86/entry: Split and inline prepare_exit_to_usermode() tip-bot for Andy Lutomirski
2015-10-06 0:48 ` [PATCH v2 36/36] x86/entry: Split and inline syscall_return_slowpath Andy Lutomirski
2015-10-09 13:16 ` [tip:x86/asm] x86/entry: Split and inline syscall_return_slowpath () tip-bot for Andy Lutomirski
2015-10-06 8:39 ` [PATCH v2 00/36] x86: Rewrite all syscall entries except native 64-bit Linus Torvalds
2015-10-06 8:49 ` Ingo Molnar
2015-10-06 18:26 ` Andy Lutomirski
2015-10-09 13:06 ` Ingo Molnar
2015-10-12 18:30 ` Richard Weinberger
2015-10-12 18:41 ` Andy Lutomirski
2015-10-12 21:02 ` Richard Weinberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56155F9A.2070209@redhat.com \
--to=dvlasenk@redhat.com \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).