Commit 0699e551 authored by Julien Thierry's avatar Julien Thierry Committed by Ingo Molnar

objtool: Clean instruction state before each function validation

When a function fails its validation, it might leave a stale state
that will be used for the validation of other functions. That would
cause false warnings on potentially valid functions.

Reset the instruction state before the validation of each individual
function.
Signed-off-by: default avatarJulien Thierry <jthierry@redhat.com>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarMiroslav Benes <mbenes@suse.cz>
Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent a70266b5
...@@ -2411,13 +2411,6 @@ static int validate_section(struct objtool_file *file, struct section *sec) ...@@ -2411,13 +2411,6 @@ static int validate_section(struct objtool_file *file, struct section *sec)
struct insn_state state; struct insn_state state;
int ret, warnings = 0; int ret, warnings = 0;
clear_insn_state(&state);
state.cfa = initial_func_cfi.cfa;
memcpy(&state.regs, &initial_func_cfi.regs,
CFI_NUM_REGS * sizeof(struct cfi_reg));
state.stack_size = initial_func_cfi.cfa.offset;
list_for_each_entry(func, &sec->symbol_list, list) { list_for_each_entry(func, &sec->symbol_list, list) {
if (func->type != STT_FUNC) if (func->type != STT_FUNC)
continue; continue;
...@@ -2435,6 +2428,12 @@ static int validate_section(struct objtool_file *file, struct section *sec) ...@@ -2435,6 +2428,12 @@ static int validate_section(struct objtool_file *file, struct section *sec)
if (!insn || insn->ignore || insn->visited) if (!insn || insn->ignore || insn->visited)
continue; continue;
clear_insn_state(&state);
state.cfa = initial_func_cfi.cfa;
memcpy(&state.regs, &initial_func_cfi.regs,
CFI_NUM_REGS * sizeof(struct cfi_reg));
state.stack_size = initial_func_cfi.cfa.offset;
state.uaccess = func->uaccess_safe; state.uaccess = func->uaccess_safe;
ret = validate_branch(file, func, insn, state); ret = validate_branch(file, func, insn, state);
......
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