Skip to content

Commit 764eef4

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
objtool: Rewrite alt->skip_orig
Really skip the original instruction flow, instead of letting it continue with NOPs. Since the alternative code flow already continues after the original instructions, only the alt-original is skipped. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 7697eee commit 764eef4

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tools/objtool/check.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
struct alternative {
3232
struct list_head list;
3333
struct instruction *insn;
34+
bool skip_orig;
3435
};
3536

3637
const char *objname;
@@ -623,9 +624,6 @@ static int add_call_destinations(struct objtool_file *file)
623624
* conditionally jumps to the _end_ of the entry. We have to modify these
624625
* jumps' destinations to point back to .text rather than the end of the
625626
* entry in .altinstr_replacement.
626-
*
627-
* 4. It has been requested that we don't validate the !POPCNT feature path
628-
* which is a "very very small percentage of machines".
629627
*/
630628
static int handle_group_alt(struct objtool_file *file,
631629
struct special_alt *special_alt,
@@ -641,9 +639,6 @@ static int handle_group_alt(struct objtool_file *file,
641639
if (insn->offset >= special_alt->orig_off + special_alt->orig_len)
642640
break;
643641

644-
if (special_alt->skip_orig)
645-
insn->type = INSN_NOP;
646-
647642
insn->alt_group = true;
648643
last_orig_insn = insn;
649644
}
@@ -808,6 +803,7 @@ static int add_special_section_alts(struct objtool_file *file)
808803
}
809804

810805
alt->insn = new_insn;
806+
alt->skip_orig = special_alt->skip_orig;
811807
list_add_tail(&alt->list, &orig_insn->alts);
812808

813809
list_del(&special_alt->list);
@@ -1883,14 +1879,22 @@ static int validate_branch(struct objtool_file *file, struct instruction *first,
18831879
insn->visited = true;
18841880

18851881
if (!insn->ignore_alts) {
1882+
bool skip_orig = false;
1883+
18861884
list_for_each_entry(alt, &insn->alts, list) {
1885+
if (alt->skip_orig)
1886+
skip_orig = true;
1887+
18871888
ret = validate_branch(file, alt->insn, state);
18881889
if (ret) {
18891890
if (backtrace)
18901891
BT_FUNC("(alt)", insn);
18911892
return ret;
18921893
}
18931894
}
1895+
1896+
if (skip_orig)
1897+
return 0;
18941898
}
18951899

18961900
switch (insn->type) {

0 commit comments

Comments
 (0)