diff options
| author | Josh Poimboeuf <jpoimboe@kernel.org> | 2022-06-24 12:52:40 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-07-23 12:54:08 +0200 |
| commit | c590fa2d2dac50e9e1ea6946506636617b2f8694 (patch) | |
| tree | e910afb3541661cdffcf9e987c91f3637209535c /tools/objtool | |
| parent | 66b37dccbc2524b675bfb2b3f4281a943cc36169 (diff) | |
| download | linux-c590fa2d2dac50e9e1ea6946506636617b2f8694.tar.gz linux-c590fa2d2dac50e9e1ea6946506636617b2f8694.tar.bz2 linux-c590fa2d2dac50e9e1ea6946506636617b2f8694.zip | |
objtool: Re-add UNWIND_HINT_{SAVE_RESTORE}
commit 8faea26e611189e933ea2281975ff4dc7c1106b6 upstream.
Commit
c536ed2fffd5 ("objtool: Remove SAVE/RESTORE hints")
removed the save/restore unwind hints because they were no longer
needed. Now they're going to be needed again so re-add them.
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/objtool')
| -rw-r--r-- | tools/objtool/check.c | 40 | ||||
| -rw-r--r-- | tools/objtool/include/objtool/check.h | 1 |
2 files changed, 41 insertions, 0 deletions
diff --git a/tools/objtool/check.c b/tools/objtool/check.c index c22115e7138b..4c18a7e28344 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1847,6 +1847,17 @@ static int read_unwind_hints(struct objtool_file *file) insn->hint = true; + if (hint->type == UNWIND_HINT_TYPE_SAVE) { + insn->hint = false; + insn->save = true; + continue; + } + + if (hint->type == UNWIND_HINT_TYPE_RESTORE) { + insn->restore = true; + continue; + } + if (hint->type == UNWIND_HINT_TYPE_REGS_PARTIAL) { struct symbol *sym = find_symbol_by_offset(insn->sec, insn->offset); @@ -3025,6 +3036,35 @@ static int validate_branch(struct objtool_file *file, struct symbol *func, state.instr += insn->instr; if (insn->hint) { + if (insn->restore) { + struct instruction *save_insn, *i; + + i = insn; + save_insn = NULL; + + sym_for_each_insn_continue_reverse(file, func, i) { + if (i->save) { + save_insn = i; + break; + } + } + + if (!save_insn) { + WARN_FUNC("no corresponding CFI save for CFI restore", + sec, insn->offset); + return 1; + } + + if (!save_insn->visited) { + WARN_FUNC("objtool isn't smart enough to handle this CFI save/restore combo", + sec, insn->offset); + return 1; + } + + insn->cfi = save_insn->cfi; + nr_cfi_reused++; + } + state.cfi = *insn->cfi; } else { /* XXX track if we actually changed state.cfi */ diff --git a/tools/objtool/include/objtool/check.h b/tools/objtool/include/objtool/check.h index 0de25d13ca92..4ba041db304f 100644 --- a/tools/objtool/include/objtool/check.h +++ b/tools/objtool/include/objtool/check.h @@ -47,6 +47,7 @@ struct instruction { unsigned long immediate; bool dead_end, ignore, ignore_alts; bool hint; + bool save, restore; bool retpoline_safe; bool entry; s8 instr; |
