All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: linux-kernel@vger.kernel.org, mbenes@suse.cz
Subject: Re: [PATCH 1/2] objtool: Optimize re-writing jump_label
Date: Fri, 8 Oct 2021 12:03:31 +0200	[thread overview]
Message-ID: <YWAXc2bhu/iTI4pv@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20211008065550.zge5zkbfrki5osv2@treble>

On Thu, Oct 07, 2021 at 11:55:50PM -0700, Josh Poimboeuf wrote:
> On Thu, Oct 07, 2021 at 11:22:12PM +0200, Peter Zijlstra wrote:
> > There's no point to re-write the jump_label NOP when it's already a NOP.
> > 
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > ---
> >  tools/objtool/check.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > --- a/tools/objtool/check.c
> > +++ b/tools/objtool/check.c
> > @@ -1397,7 +1397,7 @@ static int handle_jump_alt(struct objtoo
> >  		return -1;
> >  	}
> >  
> > -	if (special_alt->key_addend & 2) {
> > +	if ((special_alt->key_addend & 2) && orig_insn->type != INSN_NOP) {
> >  		struct reloc *reloc = insn_reloc(file, orig_insn);
> >  
> >  		if (reloc) {
> 
> While you're at it, a comment would be very helpful for that whole
> clause.

Like so?

--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1397,7 +1397,16 @@ static int handle_jump_alt(struct objtoo
 		return -1;
 	}
 
-	if (special_alt->key_addend & 2) {
+	/*
+	 * When, for whatever reason, the jump-label site cannot emit a right
+	 * sized NOP, then it can use Bit-1 of the struct static_key pointer to
+	 * indicate this instruction should be NOP'ed by objtool.
+	 *
+	 * Also see arch/x86/include/asm/jump_label.h:arch_static_branch(),
+	 * where we leave the assembler to pick between jmp.d8 and jmp.d32
+	 * based on destination offset.
+	 */
+	if ((special_alt->key_addend & 2) && orig_insn->type != INSN_NOP) {
 		struct reloc *reloc = insn_reloc(file, orig_insn);
 
 		if (reloc) {

  reply	other threads:[~2021-10-08 10:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-07 21:22 [PATCH 0/2] objtool: Avoid pointless modifications Peter Zijlstra
2021-10-07 21:22 ` [PATCH 1/2] objtool: Optimize re-writing jump_label Peter Zijlstra
2021-10-08  6:55   ` Josh Poimboeuf
2021-10-08 10:03     ` Peter Zijlstra [this message]
2021-10-08 16:28       ` Josh Poimboeuf
2021-10-07 21:22 ` [PATCH 2/2] objtool: Optimize/fix retpoline alternative generation Peter Zijlstra
2021-10-08  7:23   ` Josh Poimboeuf
2021-10-08 10:35     ` Peter Zijlstra
2021-10-08 16:39       ` Josh Poimboeuf
2021-10-09 10:42         ` 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=YWAXc2bhu/iTI4pv@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --subject='Re: [PATCH 1/2] objtool: Optimize re-writing jump_label' \
    /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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.