From: Andi Kleen <andi@firstfloor.org>
To: tglx@linutronix.de
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
torvalds@linux-foundation.org, dwmw@amazon.co.uk, pjt@google.com,
luto@kernel.org, peterz@infradead.org, thomas.lendacky@amd.com,
tim.c.chen@linux.intel.com, gregkh@linux-foundation.org,
dave.hansen@intel.com, jikos@kernel.org,
Andi Kleen <ak@linux.intel.com>
Subject: [PATCH v1 1/8] x86/entry/clearregs: Remove partial stack frame in fast system call
Date: Tue, 9 Jan 2018 17:03:21 -0800 [thread overview]
Message-ID: <20180110010328.22163-2-andi@firstfloor.org> (raw)
In-Reply-To: <20180110010328.22163-1-andi@firstfloor.org>
From: Andi Kleen <ak@linux.intel.com>
Remove the partial stack frame in the 64bit syscall fast path.
In the next patch we want to clear the extra registers, which requires
to always save all registers. So remove the partial stack frame
in the syscall fast path and always save everything.
This actually simplifies the code because the ptregs stubs
are not needed anymore.
arch/x86/entry/entry_64.S | 57 ++++-----------------------------------------------------
arch/x86/entry/syscall_64.c | 2 +-
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
arch/x86/entry/entry_64.S | 57 ++++-----------------------------------------
arch/x86/entry/syscall_64.c | 2 +-
2 files changed, 5 insertions(+), 54 deletions(-)
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 58dbf7a12a05..bbdfbdd817d6 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -234,7 +234,9 @@ GLOBAL(entry_SYSCALL_64_after_hwframe)
pushq %r9 /* pt_regs->r9 */
pushq %r10 /* pt_regs->r10 */
pushq %r11 /* pt_regs->r11 */
- sub $(6*8), %rsp /* pt_regs->bp, bx, r12-15 not saved */
+ sub $(6*8), %rsp
+ SAVE_EXTRA_REGS
+
UNWIND_HINT_REGS extra=0
/*
@@ -262,11 +264,6 @@ entry_SYSCALL_64_fastpath:
ja 1f /* return -ENOSYS (already in pt_regs->ax) */
movq %r10, %rcx
- /*
- * This call instruction is handled specially in stub_ptregs_64.
- * It might end up jumping to the slow path. If it jumps, RAX
- * and all argument registers are clobbered.
- */
#ifdef CONFIG_RETPOLINE
movq sys_call_table(, %rax, 8), %rax
call __x86_indirect_thunk_rax
@@ -293,9 +290,7 @@ entry_SYSCALL_64_fastpath:
TRACE_IRQS_ON /* user mode is traced as IRQs on */
movq RIP(%rsp), %rcx
movq EFLAGS(%rsp), %r11
- addq $6*8, %rsp /* skip extra regs -- they were preserved */
- UNWIND_HINT_EMPTY
- jmp .Lpop_c_regs_except_rcx_r11_and_sysret
+ jmp syscall_return_via_sysret
1:
/*
@@ -305,14 +300,12 @@ entry_SYSCALL_64_fastpath:
*/
TRACE_IRQS_ON
ENABLE_INTERRUPTS(CLBR_ANY)
- SAVE_EXTRA_REGS
movq %rsp, %rdi
call syscall_return_slowpath /* returns with IRQs disabled */
jmp return_from_SYSCALL_64
entry_SYSCALL64_slow_path:
/* IRQs are off. */
- SAVE_EXTRA_REGS
movq %rsp, %rdi
call do_syscall_64 /* returns with IRQs disabled */
@@ -389,7 +382,6 @@ syscall_return_via_sysret:
/* rcx and r11 are already restored (see code above) */
UNWIND_HINT_EMPTY
POP_EXTRA_REGS
-.Lpop_c_regs_except_rcx_r11_and_sysret:
popq %rsi /* skip r11 */
popq %r10
popq %r9
@@ -420,47 +412,6 @@ syscall_return_via_sysret:
USERGS_SYSRET64
END(entry_SYSCALL_64)
-ENTRY(stub_ptregs_64)
- /*
- * Syscalls marked as needing ptregs land here.
- * If we are on the fast path, we need to save the extra regs,
- * which we achieve by trying again on the slow path. If we are on
- * the slow path, the extra regs are already saved.
- *
- * RAX stores a pointer to the C function implementing the syscall.
- * IRQs are on.
- */
- cmpq $.Lentry_SYSCALL_64_after_fastpath_call, (%rsp)
- jne 1f
-
- /*
- * Called from fast path -- disable IRQs again, pop return address
- * and jump to slow path
- */
- DISABLE_INTERRUPTS(CLBR_ANY)
- TRACE_IRQS_OFF
- popq %rax
- UNWIND_HINT_REGS extra=0
- jmp entry_SYSCALL64_slow_path
-
-1:
- JMP_NOSPEC %rax /* Called from C */
-END(stub_ptregs_64)
-
-.macro ptregs_stub func
-ENTRY(ptregs_\func)
- UNWIND_HINT_FUNC
- leaq \func(%rip), %rax
- jmp stub_ptregs_64
-END(ptregs_\func)
-.endm
-
-/* Instantiate ptregs_stub for each ptregs-using syscall */
-#define __SYSCALL_64_QUAL_(sym)
-#define __SYSCALL_64_QUAL_ptregs(sym) ptregs_stub sym
-#define __SYSCALL_64(nr, sym, qual) __SYSCALL_64_QUAL_##qual(sym)
-#include <asm/syscalls_64.h>
-
/*
* %rdi: prev task
* %rsi: next task
diff --git a/arch/x86/entry/syscall_64.c b/arch/x86/entry/syscall_64.c
index 9c09775e589d..ad1ae014f943 100644
--- a/arch/x86/entry/syscall_64.c
+++ b/arch/x86/entry/syscall_64.c
@@ -8,7 +8,7 @@
#include <asm/syscall.h>
#define __SYSCALL_64_QUAL_(sym) sym
-#define __SYSCALL_64_QUAL_ptregs(sym) ptregs_##sym
+#define __SYSCALL_64_QUAL_ptregs(sym) sym
#define __SYSCALL_64(nr, sym, qual) extern asmlinkage long __SYSCALL_64_QUAL_##qual(sym)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);
#include <asm/syscalls_64.h>
--
2.14.3
next prev parent reply other threads:[~2018-01-10 1:03 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-10 1:03 x86/clearregs: Register sanitizing at kernel entry for speculation hygiene Andi Kleen
2018-01-10 1:03 ` Andi Kleen [this message]
2018-01-10 2:46 ` [PATCH v1 1/8] x86/entry/clearregs: Remove partial stack frame in fast system call Brian Gerst
2018-01-11 0:16 ` Andi Kleen
2018-01-11 0:54 ` Brian Gerst
2018-01-11 1:02 ` Andi Kleen
2018-01-11 0:55 ` Andy Lutomirski
2018-01-11 1:01 ` Andi Kleen
2018-01-11 1:01 ` Brian Gerst
2018-01-11 1:22 ` Andy Lutomirski
2018-01-11 1:47 ` Andi Kleen
2018-01-11 18:44 ` Andi Kleen
2018-01-11 2:09 ` Josh Poimboeuf
2018-01-12 3:22 ` Josh Poimboeuf
2018-01-10 1:03 ` [PATCH v1 2/8] x86/entry/clearregs: Add infrastructure to clear registers Andi Kleen
2018-01-11 19:58 ` Konrad Rzeszutek Wilk
2018-01-11 20:10 ` Andi Kleen
2018-01-10 1:03 ` [PATCH v1 3/8] x86/entry/clearregs: Clear registers for 64bit SYSCALL Andi Kleen
2018-01-11 3:35 ` Brian Gerst
2018-01-11 18:47 ` Andi Kleen
2018-01-12 3:45 ` Josh Poimboeuf
2018-01-10 1:03 ` [PATCH v1 4/8] x86/entry/retpoline: Clear extra registers for compat syscalls Andi Kleen
2018-01-10 1:03 ` [PATCH v1 5/8] x86/entry/clearregs: Clear registers for 64bit exceptions/interrupts Andi Kleen
2018-01-10 1:23 ` Andy Lutomirski
2018-01-10 1:03 ` [PATCH v1 6/8] x86/entry/clearregs: Add number of arguments to syscall tables Andi Kleen
2018-01-10 1:26 ` Andy Lutomirski
2018-01-10 4:37 ` Andi Kleen
2018-01-10 20:05 ` Andy Lutomirski
2018-01-10 1:03 ` [PATCH v1 7/8] x86/entry/clearregs: Add 64bit stubs to clear unused arguments regs Andi Kleen
2018-01-10 1:03 ` [PATCH v1 8/8] x86/entry/clearregs: Clear registers for 32bit kernel Andi Kleen
2018-01-10 1:24 ` Andy Lutomirski
2018-01-10 1:16 ` x86/clearregs: Register sanitizing at kernel entry for speculation hygiene Andy Lutomirski
2018-01-10 1:34 ` Andi Kleen
2018-01-10 1:39 ` Andy Lutomirski
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=20180110010328.22163-2-andi@firstfloor.org \
--to=andi@firstfloor.org \
--cc=ak@linux.intel.com \
--cc=dave.hansen@intel.com \
--cc=dwmw@amazon.co.uk \
--cc=gregkh@linux-foundation.org \
--cc=jikos@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=tim.c.chen@linux.intel.com \
--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
Powered by JetHome