public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: jpoimboe@redhat.com, alexandre.chartre@oracle.com
Cc: linux-kernel@vger.kernel.org, jthierry@redhat.com,
	tglx@linutronix.de, x86@kernel.org, mbenes@suse.cz
Subject: Re: [PATCH 8/8] x86/retpoline: Fix retpoline unwind
Date: Thu, 23 Apr 2020 14:59:55 +0200	[thread overview]
Message-ID: <20200423125955.GU20730@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200423125043.129313983@infradead.org>

On Thu, Apr 23, 2020 at 02:47:25PM +0200, Peter Zijlstra wrote:
> @@ -128,10 +90,16 @@
>  
>  .macro CALL_NOSPEC reg:req
>  #ifdef CONFIG_RETPOLINE
> -	ANNOTATE_NOSPEC_ALTERNATIVE
> -	ALTERNATIVE_2 __stringify(ANNOTATE_RETPOLINE_SAFE; call *%\reg),\
> -		__stringify(RETPOLINE_CALL %\reg), X86_FEATURE_RETPOLINE,\
> -		__stringify(lfence; ANNOTATE_RETPOLINE_SAFE; call *%\reg), X86_FEATURE_RETPOLINE_AMD
> +	/*
> +	 * This cannot be ALTERNATIVE_2 like with JMP_NOSPEC, because ORC
> +	 * unwind data is alternative invariant and needs stack modifying
> +	 * instructions to be in the same place for all alternatives.
> +	 *
> +	 * IOW the CALL instruction must be at the same offset for all cases.
> +	 */
> +	ALTERNATIVE "", "lfence", X86_FEATURE_RETPOLINE_AMD
> +	ALTERNATIVE __stringify(ANNOTATE_RETPOLINE_SAFE; call *%\reg), \
> +		    __stringify(call __x86_retpoline_\reg), X86_FEATURE_RETPOLINE
>  #else
>  	call	*%\reg
>  #endif
> @@ -165,16 +133,12 @@
>   * which is ensured when CONFIG_RETPOLINE is defined.
>   */
>  # define CALL_NOSPEC						\
> -	ANNOTATE_NOSPEC_ALTERNATIVE				\
> -	ALTERNATIVE_2(						\
> -	ANNOTATE_RETPOLINE_SAFE					\
> -	"call *%[thunk_target]\n",				\
> -	"call __x86_indirect_thunk_%V[thunk_target]\n",		\
> -	X86_FEATURE_RETPOLINE,					\
> -	"lfence;\n"						\
> -	ANNOTATE_RETPOLINE_SAFE					\
> -	"call *%[thunk_target]\n",				\
> -	X86_FEATURE_RETPOLINE_AMD)
> +	ALTERNATIVE("", "lfence", X86_FEATURE_RETPOLINE_AMD)	\
> +	ALTERNATIVE(ANNOTATE_RETPOLINE_SAFE			\
> +		    "call *%[thunk_target]\n",			\
> +		    "call __x86_indirect_thunk_%V[thunk_target]\n", \
> +		    X86_FEATURE_RETPOLINE)
> +

Hmm, that's a bit daft; that could be a call to
__x86_retpoline_%V[thunk_target] like for the ASM version above.

  reply	other threads:[~2020-04-23 13:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23 12:47 [PATCH 0/8] objtool vs retpoline Peter Zijlstra
2020-04-23 12:47 ` [PATCH 1/8] objtool: is_fentry_call() crashes if call has no destination Peter Zijlstra
2020-04-23 12:47 ` [PATCH 2/8] objtool: UNWIND_HINT_RET_OFFSET should not check registers Peter Zijlstra
2020-04-23 12:47 ` [PATCH 3/8] objtool: Rework allocating stack_ops on decode Peter Zijlstra
2020-04-23 15:40   ` Alexandre Chartre
2020-04-23 15:54     ` Peter Zijlstra
2020-04-24  7:06       ` Alexandre Chartre
2020-04-23 16:16     ` Peter Zijlstra
2020-04-24  9:43       ` Miroslav Benes
2020-04-23 12:47 ` [PATCH 4/8] objtool: Add support for intra-function calls Peter Zijlstra
2020-04-23 14:34   ` Miroslav Benes
2020-04-23 15:22     ` Peter Zijlstra
2020-04-24  9:37       ` Miroslav Benes
2020-04-24 14:07         ` Miroslav Benes
2020-04-23 12:47 ` [PATCH 5/8] x86/speculation: Change FILL_RETURN_BUFFER to work with objtool Peter Zijlstra
2020-04-23 15:45   ` Alexandre Chartre
2020-04-24 19:04   ` Josh Poimboeuf
2020-04-23 12:47 ` [PATCH 6/8] x86: Simplify retpoline declaration Peter Zijlstra
2020-04-24 19:09   ` Josh Poimboeuf
2020-04-23 12:47 ` [PATCH 7/8] x86: Change {JMP,CALL}_NOSPEC argument Peter Zijlstra
2020-04-23 12:47 ` [PATCH 8/8] x86/retpoline: Fix retpoline unwind Peter Zijlstra
2020-04-23 12:59   ` Peter Zijlstra [this message]
2020-04-24 19:30   ` Josh Poimboeuf
2020-04-28 18:30     ` Peter Zijlstra

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=20200423125955.GU20730@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=alexandre.chartre@oracle.com \
    --cc=jpoimboe@redhat.com \
    --cc=jthierry@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=tglx@linutronix.de \
    --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