Skip to content

Commit 10b4c4b

Browse files
jpoimboekees
authored andcommitted
objtool: Fix UNWIND_HINT_{SAVE,RESTORE} across basic blocks
If SAVE and RESTORE unwind hints are in different basic blocks, and objtool sees the RESTORE before the SAVE, it errors out with: vmlinux.o: warning: objtool: vmw_port_hb_in+0x242: objtool isn't smart enough to handle this CFI save/restore combo In such a case, defer following the RESTORE block until the straight-line path gets followed later. Fixes: 8faea26 ("objtool: Re-add UNWIND_HINT_{SAVE_RESTORE}") Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: Josh Poimboeuf <[email protected]> Link: https://lore.kernel.org/r/20240227073527.avcm5naavbv3cj5s@treble Signed-off-by: Kees Cook <[email protected]>
1 parent c5e6d3d commit 10b4c4b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tools/objtool/check.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3620,6 +3620,18 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
36203620
}
36213621

36223622
if (!save_insn->visited) {
3623+
/*
3624+
* If the restore hint insn is at the
3625+
* beginning of a basic block and was
3626+
* branched to from elsewhere, and the
3627+
* save insn hasn't been visited yet,
3628+
* defer following this branch for now.
3629+
* It will be seen later via the
3630+
* straight-line path.
3631+
*/
3632+
if (!prev_insn)
3633+
return 0;
3634+
36233635
WARN_INSN(insn, "objtool isn't smart enough to handle this CFI save/restore combo");
36243636
return 1;
36253637
}

0 commit comments

Comments
 (0)