diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-05 05:53:00 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2018-04-05 10:59:24 -0400 |
commit | dfe64506c01e57159a4c550fe537c13a317ff01b (patch) | |
tree | 4c5623bfac6ecb60eb36dec94784eda740d11c0f | |
parent | 642e7fd23353e22290e3d51719fcb658dc252342 (diff) |
x86/syscalls: Don't pointlessly reload the system call number
We have it in a register in the low-level asm, just pass it in as an
argument rather than have do_syscall_64() load it back in from the
ptregs pointer.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Andy Lutomirski <luto@kernel.org>
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: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20180405095307.3730-2-linux@dominikbrodowski.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/entry/common.c | 12 | ||||
-rw-r--r-- | arch/x86/entry/entry_64.S | 3 |
2 files changed, 8 insertions, 7 deletions
diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c index 74f6eee15179..a8b066dbbf48 100644 --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c | |||
@@ -266,14 +266,13 @@ __visible inline void syscall_return_slowpath(struct pt_regs *regs) | |||
266 | } | 266 | } |
267 | 267 | ||
268 | #ifdef CONFIG_X86_64 | 268 | #ifdef CONFIG_X86_64 |
269 | __visible void do_syscall_64(struct pt_regs *regs) | 269 | __visible void do_syscall_64(unsigned long nr, struct pt_regs *regs) |
270 | { | 270 | { |
271 | struct thread_info *ti = current_thread_info(); | 271 | struct thread_info *ti; |
272 | unsigned long nr = regs->orig_ax; | ||
273 | 272 | ||
274 | enter_from_user_mode(); | 273 | enter_from_user_mode(); |
275 | local_irq_enable(); | 274 | local_irq_enable(); |
276 | 275 | ti = current_thread_info(); | |
277 | if (READ_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY) | 276 | if (READ_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY) |
278 | nr = syscall_trace_enter(regs); | 277 | nr = syscall_trace_enter(regs); |
279 | 278 | ||
@@ -282,8 +281,9 @@ __visible void do_syscall_64(struct pt_regs *regs) | |||
282 | * table. The only functional difference is the x32 bit in | 281 | * table. The only functional difference is the x32 bit in |
283 | * regs->orig_ax, which changes the behavior of some syscalls. | 282 | * regs->orig_ax, which changes the behavior of some syscalls. |
284 | */ | 283 | */ |
285 | if (likely((nr & __SYSCALL_MASK) < NR_syscalls)) { | 284 | nr &= __SYSCALL_MASK; |
286 | nr = array_index_nospec(nr & __SYSCALL_MASK, NR_syscalls); | 285 | if (likely(nr < NR_syscalls)) { |
286 | nr = array_index_nospec(nr, NR_syscalls); | ||
287 | regs->ax = sys_call_table[nr]( | 287 | regs->ax = sys_call_table[nr]( |
288 | regs->di, regs->si, regs->dx, | 288 | regs->di, regs->si, regs->dx, |
289 | regs->r10, regs->r8, regs->r9); | 289 | regs->r10, regs->r8, regs->r9); |
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index 936e19642eab..6cfe38665f3c 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S | |||
@@ -233,7 +233,8 @@ GLOBAL(entry_SYSCALL_64_after_hwframe) | |||
233 | TRACE_IRQS_OFF | 233 | TRACE_IRQS_OFF |
234 | 234 | ||
235 | /* IRQs are off. */ | 235 | /* IRQs are off. */ |
236 | movq %rsp, %rdi | 236 | movq %rax, %rdi |
237 | movq %rsp, %rsi | ||
237 | call do_syscall_64 /* returns with IRQs disabled */ | 238 | call do_syscall_64 /* returns with IRQs disabled */ |
238 | 239 | ||
239 | TRACE_IRQS_IRETQ /* we're about to change IF */ | 240 | TRACE_IRQS_IRETQ /* we're about to change IF */ |