Commit 764eef4b authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

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: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: default avatarJosh 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: default avatarIngo Molnar <mingo@kernel.org>
parent 7697eee3
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
struct alternative { struct alternative {
struct list_head list; struct list_head list;
struct instruction *insn; struct instruction *insn;
bool skip_orig;
}; };
const char *objname; const char *objname;
...@@ -623,9 +624,6 @@ static int add_call_destinations(struct objtool_file *file) ...@@ -623,9 +624,6 @@ static int add_call_destinations(struct objtool_file *file)
* conditionally jumps to the _end_ of the entry. We have to modify these * conditionally jumps to the _end_ of the entry. We have to modify these
* jumps' destinations to point back to .text rather than the end of the * jumps' destinations to point back to .text rather than the end of the
* entry in .altinstr_replacement. * entry in .altinstr_replacement.
*
* 4. It has been requested that we don't validate the !POPCNT feature path
* which is a "very very small percentage of machines".
*/ */
static int handle_group_alt(struct objtool_file *file, static int handle_group_alt(struct objtool_file *file,
struct special_alt *special_alt, struct special_alt *special_alt,
...@@ -641,9 +639,6 @@ static int handle_group_alt(struct objtool_file *file, ...@@ -641,9 +639,6 @@ static int handle_group_alt(struct objtool_file *file,
if (insn->offset >= special_alt->orig_off + special_alt->orig_len) if (insn->offset >= special_alt->orig_off + special_alt->orig_len)
break; break;
if (special_alt->skip_orig)
insn->type = INSN_NOP;
insn->alt_group = true; insn->alt_group = true;
last_orig_insn = insn; last_orig_insn = insn;
} }
...@@ -808,6 +803,7 @@ static int add_special_section_alts(struct objtool_file *file) ...@@ -808,6 +803,7 @@ static int add_special_section_alts(struct objtool_file *file)
} }
alt->insn = new_insn; alt->insn = new_insn;
alt->skip_orig = special_alt->skip_orig;
list_add_tail(&alt->list, &orig_insn->alts); list_add_tail(&alt->list, &orig_insn->alts);
list_del(&special_alt->list); list_del(&special_alt->list);
...@@ -1883,7 +1879,12 @@ static int validate_branch(struct objtool_file *file, struct instruction *first, ...@@ -1883,7 +1879,12 @@ static int validate_branch(struct objtool_file *file, struct instruction *first,
insn->visited = true; insn->visited = true;
if (!insn->ignore_alts) { if (!insn->ignore_alts) {
bool skip_orig = false;
list_for_each_entry(alt, &insn->alts, list) { list_for_each_entry(alt, &insn->alts, list) {
if (alt->skip_orig)
skip_orig = true;
ret = validate_branch(file, alt->insn, state); ret = validate_branch(file, alt->insn, state);
if (ret) { if (ret) {
if (backtrace) if (backtrace)
...@@ -1891,6 +1892,9 @@ static int validate_branch(struct objtool_file *file, struct instruction *first, ...@@ -1891,6 +1892,9 @@ static int validate_branch(struct objtool_file *file, struct instruction *first,
return ret; return ret;
} }
} }
if (skip_orig)
return 0;
} }
switch (insn->type) { switch (insn->type) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment