Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dfe64506 authored by Linus Torvalds's avatar Linus Torvalds Committed by Ingo Molnar
Browse files

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: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarDominik 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: default avatarIngo Molnar <mingo@kernel.org>
parent 642e7fd2
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -266,14 +266,13 @@ __visible inline void syscall_return_slowpath(struct pt_regs *regs)
}
}


#ifdef CONFIG_X86_64
#ifdef CONFIG_X86_64
__visible void do_syscall_64(struct pt_regs *regs)
__visible void do_syscall_64(unsigned long nr, struct pt_regs *regs)
{
{
	struct thread_info *ti = current_thread_info();
	struct thread_info *ti;
	unsigned long nr = regs->orig_ax;


	enter_from_user_mode();
	enter_from_user_mode();
	local_irq_enable();
	local_irq_enable();

	ti = current_thread_info();
	if (READ_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY)
	if (READ_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY)
		nr = syscall_trace_enter(regs);
		nr = syscall_trace_enter(regs);


@@ -282,8 +281,9 @@ __visible void do_syscall_64(struct pt_regs *regs)
	 * table.  The only functional difference is the x32 bit in
	 * table.  The only functional difference is the x32 bit in
	 * regs->orig_ax, which changes the behavior of some syscalls.
	 * regs->orig_ax, which changes the behavior of some syscalls.
	 */
	 */
	if (likely((nr & __SYSCALL_MASK) < NR_syscalls)) {
	nr &= __SYSCALL_MASK;
		nr = array_index_nospec(nr & __SYSCALL_MASK, NR_syscalls);
	if (likely(nr < NR_syscalls)) {
		nr = array_index_nospec(nr, NR_syscalls);
		regs->ax = sys_call_table[nr](
		regs->ax = sys_call_table[nr](
			regs->di, regs->si, regs->dx,
			regs->di, regs->si, regs->dx,
			regs->r10, regs->r8, regs->r9);
			regs->r10, regs->r8, regs->r9);
+2 −1
Original line number Original line Diff line number Diff line
@@ -233,7 +233,8 @@ GLOBAL(entry_SYSCALL_64_after_hwframe)
	TRACE_IRQS_OFF
	TRACE_IRQS_OFF


	/* IRQs are off. */
	/* IRQs are off. */
	movq	%rsp, %rdi
	movq	%rax, %rdi
	movq	%rsp, %rsi
	call	do_syscall_64		/* returns with IRQs disabled */
	call	do_syscall_64		/* returns with IRQs disabled */


	TRACE_IRQS_IRETQ		/* we're about to change IF */
	TRACE_IRQS_IRETQ		/* we're about to change IF */