mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Andy Lutomirski <luto@kernel.org>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	Borislav Petkov <bp@alien8.de>, Brian Gerst <brgerst@gmail.com>,
	David Laight <David.Laight@aculab.com>,
	Kees Cook <keescook@chromium.org>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH 4/6] Unsuck "x86/entry/64: Create a percpu SYSCALL entry trampoline"
Date: Sat, 2 Dec 2017 09:18:40 -0600	[thread overview]
Message-ID: <20171202151840.7qeuvg6nxoqmat6a@treble> (raw)
In-Reply-To: <8000c2851af491df898d232ecb7500857e2716ea.1512109321.git.luto@kernel.org>

On Thu, Nov 30, 2017 at 10:29:44PM -0800, Andy Lutomirski wrote:
> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> index caf74a1bb3de..28f4e7553c26 100644
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -180,14 +180,24 @@ ENTRY(entry_SYSCALL_64_trampoline)
>  
>  	/*
>  	 * x86 lacks a near absolute jump, and we can't jump to the real
> -	 * entry text with a relative jump, so we fake it using retq.
> +	 * entry text with a relative jump.  We could push the target
> +	 * address and then use retq, but this destroys the pipeline on
> +	 * many CPUs (wasting over 20 cycles on Sandy Bridge).  Instead,
> +	 * spill RDI and restore it in a second-stage trampoline.
>  	 */
> -	pushq	$entry_SYSCALL_64_after_hwframe
> -	retq
> +	pushq	%rdi
> +	movq	$entry_SYSCALL_64_stage2, %rdi
> +	jmp	*%rdi
>  END(entry_SYSCALL_64_trampoline)
>  
>  	.popsection
>  
> +ENTRY(entry_SYSCALL_64_stage2)
> +	UNWIND_HINT_EMPTY
> +	popq	%rdi
> +	jmp	entry_SYSCALL_64_after_hwframe
> +END(entry_SYSCALL_64_stage2)
> +
>  ENTRY(entry_SYSCALL_64)
>  	UNWIND_HINT_EMPTY
>  	/*

Another crazy idea:

	call	1f
1:	movq	$entry_SYSCALL_64_after_hwframe, (%rsp)
	ret

Does that fix the regression?

-- 
Josh

  reply	other threads:[~2017-12-02 15:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-01  6:29 [PATCH 0/6] WIP.x86/mm fixes Andy Lutomirski
2017-12-01  6:29 ` [PATCH 1/6] x86/orc: Don't bail on stack overflow Andy Lutomirski
2017-12-01  6:29 ` [PATCH 2/6] Fixup "x86/asm: Fix assumptions that the HW TSS is at the beginning of cpu_tss" Andy Lutomirski
2017-12-01  6:29 ` [PATCH 3/6] Fixup "x86/asm: Remap the TSS into the cpu entry area" Andy Lutomirski
2017-12-01  6:29 ` [PATCH 4/6] Unsuck "x86/entry/64: Create a percpu SYSCALL entry trampoline" Andy Lutomirski
2017-12-02 15:18   ` Josh Poimboeuf [this message]
2017-12-02 16:05     ` Andy Lutomirski
2017-12-01  6:29 ` [PATCH 5/6] Fixup "x86/entry/64: Move the IST stacks into cpu_entry_area" Andy Lutomirski
2017-12-01  6:29 ` [PATCH 6/6] x86/entry/64: Make cpu_entry_area.tss read-only 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=20171202151840.7qeuvg6nxoqmat6a@treble \
    --to=jpoimboe@redhat.com \
    --cc=David.Laight@aculab.com \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=peterz@infradead.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

all inboxes | Powered by JetHome®