mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Jason Gerecke <killertofu@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Jason Baron <jbaron@akamai.com>,
	Jason Gerecke <jason.gerecke@wacom.com>,
	Ard Biesheuvel <ardb@kernel.org>,
	"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH] RFC: x86/jump_label: Mark arguments as const to satisfy asm constraints
Date: Fri, 12 Feb 2021 09:40:59 -0500	[thread overview]
Message-ID: <20210212094059.5f8d05e8@gandalf.local.home> (raw)
In-Reply-To: <20210211214848.536626-1-jason.gerecke@wacom.com>

On Thu, 11 Feb 2021 13:48:48 -0800
Jason Gerecke <killertofu@gmail.com> wrote:

> When compiling an external kernel module with `-O0` or `-O1`, the following
> compile error may be reported:
> 
>     ./arch/x86/include/asm/jump_label.h:25:2: error: impossible constraint in ‘asm’
>        25 |  asm_volatile_goto("1:"
>           |  ^~~~~~~~~~~~~~~~~
> 
> It appears that these lower optimization levels prevent GCC from detecting
> that the key/branch arguments can be treated as constants and used as
> immediate operands. To work around this, explicitly add the `const` label.

Yes this makes sense. The "i" constraint needs to be a constant.

Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve

> 
> Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> ---
> Marked RFC since I'm not familiar with this subsystem or the asm blocks that
> are impacted. Extra-close inspection would be appreciated.
> 
>  arch/x86/include/asm/jump_label.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h
> index 06c3cc22a058..7f2006645d84 100644
> --- a/arch/x86/include/asm/jump_label.h
> +++ b/arch/x86/include/asm/jump_label.h
> @@ -20,7 +20,7 @@
>  #include <linux/stringify.h>
>  #include <linux/types.h>
>  
> -static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
> +static __always_inline bool arch_static_branch(struct static_key * const key, const bool branch)
>  {
>  	asm_volatile_goto("1:"
>  		".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t"
> @@ -36,7 +36,7 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran
>  	return true;
>  }
>  
> -static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
> +static __always_inline bool arch_static_branch_jump(struct static_key * const key, const bool branch)
>  {
>  	asm_volatile_goto("1:"
>  		".byte 0xe9\n\t .long %l[l_yes] - 2f\n\t"


  reply	other threads:[~2021-02-12 14:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-11 21:48 Jason Gerecke
2021-02-12 14:40 ` Steven Rostedt [this message]
2021-02-12 15:27   ` Peter Zijlstra
2021-02-12 15:55     ` Jason Gerecke
2021-02-12 16:14 ` Josh Poimboeuf
2021-03-03  8:15 ` [tip: locking/core] " tip-bot2 for Jason Gerecke
2021-03-06 11:54 ` tip-bot2 for Jason Gerecke

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=20210212094059.5f8d05e8@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=ardb@kernel.org \
    --cc=jason.gerecke@wacom.com \
    --cc=jbaron@akamai.com \
    --cc=jpoimboe@redhat.com \
    --cc=killertofu@gmail.com \
    --cc=linux-kernel@vger.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®